Folder101   Home Notes Quiz Assigns Info  
Forum Forum
101 Home 101
 
  C++ Level 2

Practice Quiz 3 - Data Types, Variables and Constants


There are 10 questions in this quiz

Question 1: Multiple Choice       

Which of the following data types does NOT have a range that include negative numbers:

Choice 1 short int
Choice 2 unsigned long
Choice 3 float
Choice 4 double

Question 2: Multiple Choice       

Which of the following is NOT a valid variable name?

Choice 1 _account
Choice 2 $money
Choice 3 account2003
Choice 4 %percentage

Question 3: Multiple Choice       

Which of the following statements is TRUE?

Choice 1 an integer variable is initialized to 0 by default
Choice 2 a variable must be initialized at declaration time
Choice 3 an integer variable is not initialized by default
Choice 4 a variable is initialized then declared

Question 4: Multiple Choice      

The data type for a number such as -123760.023 is a:

Choice 1 unsigned long
Choice 2 double
Choice 3 long
Choice 4 unsigned int

Question 5: Multiple Choice       

Which one of the following is a character literal?

Choice 1 "a"
Choice 2 ch
Choice 3 /c
Choice 4 'a'

Question 6: Multiple Choice     

Which one of the following statements is FALSE?

Choice 1 a literal is a particular value
Choice 2 a constant's value can be changed at runtime
Choice 3 a variable's value can be changed at runtime
Choice 4 a literal's value cannot be changed at runtime

Question 7: Multiple Choice       

Which of the following is an INCORRECT way of declaring a constant

Choice 1 const float NUM = 19.75;
Choice 2 #define INVALID 0
Choice 3 const char ABC[] = {'a', 'b', 'c'};
Choice 4 const int DAY 12;

Question 8: Multiple Choice       

Which one of the following statements is FALSE?

Choice 1 C++ is case sensitive
Choice 2 const is better than #define because you have to specify the data type
Choice 3 declaring int num = -1.5; would give you compiler warning
Choice 4 declaring int num = -1.5; would convert num to a float

Question 9: Multiple Choice       

Which one of the following declarations is INVALID for a 32-bit system?

Choice 1 int i = 40000;
Choice 2 int i = -40000;
Choice 3 long int i = -40000;
Choice 4 short int i = 40000;

Question 10: Multiple Choice       

Which one of the following declarations will give a warning or error?

Choice 1 unsigned long lg = 5000000000;
Choice 2 unsigned long lg = -60;
Choice 3 char ch = 124;
Choice 4 int num = 'a';