Simple summation program second code of Cinclude include usi
Solution
//START PROGRAM
// declare variable p,q,r
int p,q,r;
// ask for input from user
cout << \"Enter 3 integers separated by space: \ \";
// user number integers p, q, and r
cin >> p >> q >> r;
// display the result
cout << \"sum of the \" << p << \", \" << q << \", \" << r << \" is \" << (p+q+r) << endl;
// END PROGRAM
sample ouput:
Enter 3 integers separated by space:
1 7 3
sum of the 1, 7, 3 is 11
/********************************************************************************/
//START PROGRAM
// declare variables
int p,q,r,s,t,u,v,w;
// ask for input from user
cout << \"Enter 8 integers separated by space: \ \";
// user number integers p, q, and r
cin >> p >> q >> r >> s >> t >> u >> v << w;
//pause program and wait for a keyboard input to continue
system(\"pause\");
// display the result
cout << \"sum of all numbers = \" << (p+q+r+s+t+u+v+w) << endl;
// END PROGRAM
sample ouput:
Enter 8 integers separated by space:
1 2 3 4 5 6 7 8
sum of all the numbers = 36
