Write a C++ statement to accomplish each of the following task: Declare variables sum and x to be of type int. Initialize variable x to 1. Initialize variable sum to 0 Add variable x to variable sum and assign the result to variable sum. Print "The sum is: " followed by the value of variable sum .
Solution
- int sum, x;
- x = 1;
- sum = 0;
- sum += x;
- cout << "The sum is: " <<
sum << endl;
If You Enjoyed This, Take 5 Seconds To Share It
0 Questions:
Post a comment