CSCI 240 - Set 2 Quiz Questions
1. (2) What instruction will display data on the screen
from a C++ program?
a. int
b. cin
c. cout
d. display
2. (2) About how many decimal places of accuracy does a float have?
a. 31
b.12
c. 6
d. 4
3. (2) The formula for converting a Fahrenheit temperature to Centigrade is 5/9(F - 32). What is wrong with writing it in C++ as
C = 5/9 * (F - 32);
assuming that C and F are both declared as doubles, and F has a valid value.
4. (2) What is the value of the expression 25 % 3?
a. 8
b. 1
c. 0
d. undefined
5. (3) Explain in detail what the following instruction does (assuming i is declared as int):
cin >> i;
6. (3) Suppose you have two integer variables (named num and sum) with valid values. Write a single cout instruction to display them as follows:
num is __
sum is __
the underscore characters will show the actual values in num and sum - for example,
num is 4
sum is 24
7. (4) Write a complete program which asks the user to enter two floating point numbers and then prints out the integer part of the sum of the two numbers. For example, if the user enters 2.4 and 2.5, the program will print 4 as the result.