Write C++ statements to accomplish each of the following tasks.

a) Declare variables sum and x to be of type int.
b) Set variable x to 1.
c) Set variable sum to 0.
d) Add variable x to variable sum and assign the result to variable sum.
e) Print "The sum is: " followed by the value of variable sum.


a) int sum;
int x;
b) x = 1;
c) sum = 0;
d) sum += x;
or
sum = sum + x;
e) cout << "The sum is: " << sum << endl;

Computer Science & Information Technology

You might also like to view...

Click ____ to move a stacked object toward the top of the stack.

A. Move Forward B. Bring Forward C. Send Forward D. Slide Forward

Computer Science & Information Technology

Which of the following statements is false?

a. IntStream methods range and rangeClosed each produce an ordered sequence of int values. b. IntStream methods range and rangeClosed take two int arguments representing the range of values. c. Method range produces a sequence of values from its first argument up to its second argument. d. Method rangeClosed produces a sequence of values including both of its arguments.

Computer Science & Information Technology

A(n) ________ object will maintain a connection between the source and destination files, storing information in the source file

Fill in the blank(s) with correct word

Computer Science & Information Technology

From within Word, you can search through various forms of reference information.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology