Combine the statements that you wrote in exercise into a


Question: Combine the statements that you wrote in Exercise into a program that calculates the sum of the integers from 1 to 10. Use the while statement to loop through the calculation and increment statements. The loop should terminate when the value of x becomes 11.

Exercise: Write a C statement to accomplish each of the following tasks.

a) Define 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.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Combine the statements that you wrote in exercise into a
Reference No:- TGS02403560

Now Priced at $10 (50% Discount)

Recommended (98%)

Rated (4.3/5)