Input and Output With C++– Hacker Rank Solution | HackerRank Programming Solutions | HackerRank C++ Solutions

Hello Programmers/Coders, Today we are going to share solutions of Programming problems of HackerRank of Programming Language C++ . At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight you profile to the recruiters.

In this post, you will find the solution for Input and Output in C++-HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.

Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.

Introduction To C++

C++ is a general-purpose programming language that was developed as an enhancement of the C language to include object-oriented paradigm. It is an imperative and a compiled language. 

C++ is a middle-level language rendering it the advantage of programming low-level (drivers, kernels) and even higher-level applications (games, GUI, desktop apps etc.). The basic syntax and code structure of both C and C++ are the same. 

C++ programming language was developed in 1980 by Bjarne Stroustrup at bell laboratories of AT&T (American Telephone & Telegraph), located in U.S.A. Bjarne Stroustrup is known as the founder of C++ language.

Input and Output With C++


In this challenge, we’re practicing reading input from stdin and printing output to stdout.In C++, you can read a single whitespace-separated token of input using cin, and print output to stdout using cout. For example, let’s say we declare the following variables:

string s;
int n;

and we want to use cin to read the input “High 5” from stdin. We can do this with the following code:

cin >> s >> n;

The above code reads the first word (“High”) from stdin and saves it as string s, then reads the second word (“5”) from stdin and saves it as integer n. If we want to print these values to stdout, we write the following code:

cout << s << " " << n << endl;

The above code prints the contents of string s, which is the word “High”. Then it prints a single space (” “), followed by the contents of integer n. Because we also want to ensure that nothing else is printed on this line, we end our line of output with a newline via endl. This results in the following output:

High 5


numbers from stdin and print their sum to stdout.Note: If you plan on completing this challenge in C instead of C++, you’ll need to use format specifiers with printf and scanf.

Input Format

A single line containing 3 space-separated integers: ab and c.4


  •  1<=a,b,c<=1000

Output Format

Print the sum of the three numbers on a single line.

Sample Input

1 2 7

Sample Output


Explanation :

The sum of the three numbers is  1 + 2 + 7 = 10.

Input and Output – Hacker Rank 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 a,b,c,d;
    cin >>a >>b >>c;
    d = a+b+c;
    return 0;

Leave a Comment

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock