Sunday, 5 October 2014

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 .

Leave a Comment

Solution

  1. int sum, x;
  2. x = 1;
  3. sum = 0;
  4. sum += x;
  5. cout << "The sum is: " << sum << endl;
If You Enjoyed This, Take 5 Seconds To Share It

0 Questions: