Professional Documents
Culture Documents
Assignment 1 in Computer Programming
Assignment 1 in Computer Programming
2. Can a C++ program have two different variables with the names aVariable and
avariable?
Answer: Yes.
3. Give the declaration for a variable called count of type int. The variable should be
initialized to zero in the declaration.
4. Give the declaration for two variables of type double. The variables are to be named
rate and time. Both variables should be initialized to zero in the declaration.
5. Write a declaration for two variables called miles and flowRate. Declare the variable
miles to be of type int and initialize it to zero in the declaration. Declare the variable
flowRate to be of type double and initialize it to 50.75 in the declaration.
6. Write a C++ assignment statement that will set the value of the variable interest to the
value of the variable balance multiplied by 0.08.
7. Write a C++ assignment statement that will set the value of the variable interest to the
value of the variable balance multiplied by the value of the variable rate. The variables
are of type double.
8. Write a C++ assignment statement that will increase the value of the variable count by
3. The variable type is int.
9. Write a C++ assignment statement that will decrease the value of the variable count by
5. The variable type is int.
Answer: count = count – 5;
10. Write a C++ assignment statement that will compute the area of a rectangle.