Code Learning#CPP#7583
Back
Stream Extraction from Input
Source Code
Run Output
Code Understanding
This program takes two numbers from the user and shows their sum.
• #include lets us use input (cin) and output (cout).
• double num1, num2; creates two variables to store decimal numbers.
• std::cout <> num1 >> num2; reads two numbers entered by the user.
• double sum = num1 + num2; adds the two numbers.
• std::cout << "Sum of numbers = " << sum << std::endl; shows the total.
• return 0; ends the program.
