In: Computer Science
C++ Create the code
Read numbers from stdin and print their sum to stdout.
Input Format
One line that contains space-separated integers:a , b, c and .
Constraints
Output Format
Print the sum of the three numbers on a single line.
Sample Input
1 2 7
Sample Output
10
Explanation
The sum of the three numbers is 1+2+7=10
Here is the code with an attached screenshot of the input and output:-
//using iostream header file which contains definitions of cin and cout which are being used
#include <iostream>
//using namespace to define the context in which names are being defined
using namespace std;
//Defining the main function
int main()
{
//Delaring the variables to be used
int a,b,c,sum;
//Input a
cin >> a;
//Input b
cin >> b;
//Input c
cin >> c;
//Adding the number
sum = a+b+c;
//Output the Sum
cout<<sum;
//Return statement of the main function
return 0;
}
Screenshot of the Code with Input/Output:-