#include <iostream> using namespace std; int main(){ int sum1 = 100+50; int sum2 = sum1+250; int sum3 = sum2+sum2; cout<< sum1 << "\n"; cout<< sum2 << "\n"; cout<< sum3 << "\n"; return 0; }

Explanation of the Code

The given C++ code calculates the sum of three numbers and prints the results.

  1. Initialization of Variables:
  2. sum1 is initialized as the sum of 100 and 50.
  3. sum2 is initialized as the sum of sum1 and 250.
  4. sum3 is initialized as the sum of sum2 and sum2.

  5. Printing the Results:

  6. The value of sum1 (150) is printed.
  7. The value of sum2 (400) is printed.
  8. The value of sum3 (800) is printed.

  9. Return Statement:

  10. The main function returns 0, indicating successful execution of the program.

The code essentially performs arithmetic operations to calculate the sum of the given numbers and then prints the results.

#include <iostream>
using namespace std;

int main() {
    int sum1 = 100 + 50;
    int sum2 = sum1 + 250;
    int sum3 = sum2 + sum2;

    cout << sum1 << "\n";
    cout << sum2 << "\n";
    cout << sum3 << "\n";

    return 0;
}