Question

CHAPTER 6 QUESTION 1 Which of these names follows the naming conventions for constants presented in...

CHAPTER 6

QUESTION 1 Which of these names follows the naming conventions for constants presented in this chapter? a. WeeksInYear b. Weeks_In_Year c. weeks_in_year d. WEEKS_IN_YEAR 1 points QUESTION 2 Which of the following data types can you not use to store the value 500? a. float b. char c. int d. double 1 points QUESTION 3 What values are in the vector named pressures after the following code is executed? vector pressures; pressures.push_back(32.4); pressures.push_back(33.5); pressures.insert(pressures.begin(), 34.2); int index = 2; pressures.insert(pressures.begin() + index, 31.8); pressures.push_back(33.3); index = 1; pressures.erase(pressures.begin() + index); a. 34.2, 33.5, 31.8, 33.3 b. 34.2, 33.5, 33.3 c. 34.2, 31.8, 33.5, 33.3 d. 34.2, 31.8, 33.3 1 points QUESTION 4 If the result of an arithmetic expression is assigned to a variable with a type that could cause a loss of data when the conversion is performed, you should a. modify the code so it uses a data type that won’t cause a loss of data b. explicitly cast the data so an error doesn’t occur at runtime c. add code that checks for any errors that may be caused by the conversion d. explicitly cast the data to indicate that you intend to perform the conversion 1 points QUESTION 5 What is the value of the string named phone after the following code is executed? string phone = "555 555 1212"; phone.insert(0, "("); phone.insert(4, ")"); phone.insert(9, "."); phone.erase(10, 1); a. (555 )555. 1212 b. (555) 555. 1212; c. (555) 555.1212 d. (555)555.1212; 1 points QUESTION 6 What is the value of the variable named street after the following code is executed? string address = "123 Main St., Somewhere, CA 93299"; string street = ""; int index1 = address.find('.'); int index2 = address.find(','); if (index1 > -1 && index2 > -1) { if (index1 < index2) { street = address.substr(0, index1); } else { street = address.substr(0, index2); } } a. "123 Main St" b. "" c. "123 Main St.," d. "123 Main St." 1 points QUESTION 7 What will happen when the following code is executed? string password = "B286!899-4389"; for (int i = 1; i < password.size(); ++i) { cout << password[i] << ' '; } a. Each character of the password except for the last character will be displayed on the console. b. Each character of the password will be displayed on the console, and then an out_of_range exception will occur. c. Each character of the password will be displayed on the console. d. Each character of the password except for the first character will be displayed on the console. 1 points QUESTION 8 What happens if an integer variable is assigned a value that’s too big for its type? a. The variable will overflow and be reduced to the type’s maximum value. b. Zero will be assigned to the variable. c. The variable will overflow and wrap around to the type’s minimum value. d. An error will occur. 1 points QUESTION 9 Type conversion occurs automatically when a. you assign the result of an arithmetic expression with one data type to a variable of another data type b. you perform an arithmetic operation with different data types c. you perform a comparison operation with different data types d. all of the above e. a and b only 1 points QUESTION 10 Given two double variables named x and y, which of the following statements could you use to initialize both variables to a value of 0.0? a. x | y = 0.0; b. x = y = 0.0; c. x, y = 0.0; d. none of the above

0 0
Add a comment Improve this question Transcribed image text
Answer #1

QUESTION 1

d. WEEKS_IN_YEAR

QUESTION 2

b. char

QUESTION 3

c. 34.2, 31.8, 33.5, 33.3

pressures.push_back(32.4);
   pressures.push_back(33.5); // 32.4 33.5
   pressures.insert(pressures.begin(), 34.2); // 34.2 32.4 33.5
   int index = 2;
   pressures.insert(pressures.begin() + index, 31.8); // 34.2 32.4 31.8 33.5
   pressures.push_back(33.3); // 34.2 32.4 31.8 33.5 33.3
   index = 1;
   pressures.erase(pressures.begin() + index); // 34.2 31.8 33.5 33.3
  

QUESTION 4

d. explicitly cast the data to indicate that you intend to perform the conversion

QUESTION 5

c. (555) 555.1212

QUESTION 6

a. "123 Main St"

QUESTION 7

d. Each character of the password except for the first character will be displayed on the console.

index starts from 1 not 0 . Output = 2 8 6 ! 8 9 9 - 4 3 8 9

QUESTION 8

d. An error will occur.

QUESTION 9

b. you perform an arithmetic operation with different data types

QUESTION 10 G

b. x = y = 0.0;

Do ask if any doubt. Please upvote.

Add a comment
Know the answer?
Add Answer to:
CHAPTER 6 QUESTION 1 Which of these names follows the naming conventions for constants presented in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • QUESTION 1 Given two double variables named x and y, which of the following statements could...

    QUESTION 1 Given two double variables named x and y, which of the following statements could you use to initialize both variables to a value of 0.0? a. x | y = 0.0; b. x = y = 0.0; c. x, y = 0.0; d. none of the above 1 points    QUESTION 2 When you use a range-based for loop with a vector, you a. can avoid out of bounds access b. must still use a counter variable c....

  • Eclipse Java Oxygen Question 11 pts A compile-time error occurs when Group of answer choices c....

    Eclipse Java Oxygen Question 11 pts A compile-time error occurs when Group of answer choices c. there’s a syntax error in a Java statement a. the Java compiler can’t be located b. bytecodes can’t be interpreted properly c. there’s a syntax error in a Java statement Flag this Question Question 21 pts An error that lets the application run but produces the wrong results is known as a Group of answer choices d. syntax error c. logic error a. runtime...

  • QUESTION 1 What will be displayed as a result of executing the following code? int   x...

    QUESTION 1 What will be displayed as a result of executing the following code? int   x = 5, y = 20; x += 32; y /= 4; cout <<"x = " << x <<"y = " << y; A. x = 32, y = 4 B. x = 9, y = 52 C. x = 37, y = 5 D. x = 160, y = 80 8 points    QUESTION 2 What will be the displayed when the following code...

  • ,,1. Which of the following statments are valid C++ statements? A) cout << "Hello World" :...

    ,,1. Which of the following statments are valid C++ statements? A) cout << "Hello World" : B) cout << Hello World; C) cout << "Hello " << "World" ; D) cout << "Hello" << "World" ; 2. What is the difference between the literals 'A' and "A"? ,3. Read the input from user; Check for valid entries If input is invalid: print an error message; else: calculate the result and print to the console; exit; The code snippet above may...

  • 1. You are given a C file which contains a partially completed program. Follow the instructions...

    1. You are given a C file which contains a partially completed program. Follow the instructions contained in comments and complete the required functions. You will be rewriting four functions from HW03 (initializeStrings, printStrings, encryptStrings, decryptStrings) using only pointer operations instead of using array operations. In addition to this, you will be writing two new functions (printReversedString, isValidPassword). You should not be using any array operations in any of functions for this assignment. You may use only the strlen() function...

  • QUESTION 1 Which of the following Python variable names has syntax error ? OA. A. CSC121...

    QUESTION 1 Which of the following Python variable names has syntax error ? OA. A. CSC121 OB. B. CSC121 Oc. C. CSC-121 D. None of the above QUESTION 2 What data type will Python use to store the value of num_students ? num_students = 17.0 A. floating point number (i.e. float) OB. B. integer (i.e. int) Oc. string (i.e. str) Od. D. None of the above

  • Please answer and explain thank you. Question 1 What will be printed when the following code...

    Please answer and explain thank you. Question 1 What will be printed when the following code is executed? double x = 45678.259; System.out.printf("%,.2f", x); Group of answer choices 45678.259 0,045,678.26 45,678.26 45,678.3 Question 2 What will be printed when the following code is executed? double x = 45678.259; String output = String.format("%,.1f", x); System.out.println(output); Group of answer choices 45678.259 45,678.259 45,678.26 45,678.3 Question 3 What will be the value of ans after the following code has been executed? int ans=0;...

  • 1) Which of the following is the name of a local variable in the Strange class...

    1) Which of the following is the name of a local variable in the Strange class below? public class Strange{ public static final int MAX = 5; public static void unknown(){ int number = 0; for (int i = MAX; i >= 1; i--) number += i * i; System.out.println(number); } public static void main(String[] a){ unknown(); } } a) Strange b) int c) MAX d) number e) main 2) Which of the following is NOT a method of the...

  • In this assignment, you will write one (1) medium size C program. The program needs to...

    In this assignment, you will write one (1) medium size C program. The program needs to be structured using multiple functions, i.e., you are required to organize your code into distinct logical units. The following set of instructions provide the specific requirements for the program. Make sure to test thoroughly before submitting. Write   a   program,   named   program1.c,   that   reads   and   processes   employee   records   (data   about   an   employee).   Each   employee   record   must   be   stored   using   a   struct   that   contains   the   following  ...

  • Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C -...

    Question 1 An array is NOT: A - Made up of different data types. B - Subscripted by integers. C - A consecutive group of memory chunks. D - None of the choices. Question 2 How many times is the body of the loop executed? int i=1; while(true) { cout << i; if(++i==5) break; } A - Forever B - 4 C - 5 D - 6 E - 0 Question 3 What is wrong with the following piece of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT