In this HackerRank Input and Output problem in c++ programming language, you need to Read 3 numbers from stdin and print their sum to stdout.
HackerRank Input and Output problem solution in c++ programming.
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { int sum = 0; int x, y, z; cin >> x >> y >> z; sum = x + y + z; cout << sum << endl; return 0; }
Second solution
#include <iostream> using namespace std; int main() { int a; int b; int c; cin >> a >> b >> c; cout << a + b + c << endl; return 0; }
Third solution
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int i = 0; int sum = 0; while (cin >> i) { sum += i; } cout << sum << endl; return 0; }
0 Comments