C++ Quiz on Datatypes
1. 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
2. How would you declare an integer called sum and initialize it to 10?
a) int sum 10;
b) int sum=10;
c) double sum=10;
3. How would you delcare a double called add and initialize it to 5?
a) double add 5;
b) double add=5
c) double add=5;
4. What is the correct way to print integer sum to the screen?
a) cout<<sum<<endl;
b) cout"sum"<<endl;
c) cout>>sum>>endl;
5. Is it legal to declare multiple integers like this, int sum,age,group;
a) yes
b) no
6. What do double data types hold?
a) integers
b) two integers
c) decimals
7. What is the correct way to input in an integer called check?
a) cout>>"check";
b) cin>>check;
c) cin<<check;
8. What is the correct way to input in a double called sum?
a) cin<<sum;
b) cout>>sum;
c) cin>>sum;
9. Why shouldn't integers be divided by integers?
a)Their values will be truncated
b) The compiler will give you an error message
c) your program will automatically crash