...

Wednesday 17 December 2014

Quiz -- C++ Data Types

1. How would you declare an integer called num and initialize it to 10?
A. double num = 10;
B. int num = 10;
C. int num == 10;
D. int num 10;

2. What is the correct way to write a comment in C++ ?
A. /this is comment/
B. \\this is a comment
C. //this is a comment
D. None of the above.

3. How would you declare a double called sum and initialize it to 15?
A. double add 15;
B. add double = 15;
C. double add 15
D. double add = 15;

4. What do double data types hold?
A. two integers
B. decimals
C. one integer
D. whole numbers

5. What is the correct way to print integer add to the screen?
A. cout<<add<<endl;
B. cout<<"add"<<endl;
C. cout add;
D. cout>>add>>endl;
 
6. Which is the correct way to declare multiple integers?
A. int sum; num; age;
B. int sum, int num, int age;
C. int sum, num, age;
D. All of the above.

7. What is the correct way to input in a double called sum?
A. cout>>sum;
B. cin<<"sum";
C. cin>>sum
D. cin>>sum;


8. What is wrong with "int long = 9200000?
A. Out of range value
B. Invalid data type
C. Invalid name for variable
D. All of the above

9. How much memory a character takes to store the value?
A. 1 byte
B. 4 bytes
C. 8 bytes
D. 16 bytes

10. How much memory an integer takes to store the value?
A. 1 byte
B. 4 bytes
C. 8 bytes
D. 16 bytes







   







ANSWER KEY

1. (B)   2. (C)   3. (D)   4. (B)   5. (A)   6. (C)   7. (D)   8. (C)   9. (A)   10. (B)

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Favorites More

 
Design by MA Technologies | Bloggerized by Computer Science Prevails