Detailed Print – CSKC
Sign In

Search

siteicon
Code Learning#CPP#7583 Back

Stream Extraction from Input

Source Code

		 

Click to open popup

Run Output

Please input two numbers: 11.23 34.54
Sum of numbers = 45.77

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.