# HackerRank Solution For Input and Output In C++

Problem:- Hacker Rank Solution Program In C++ For " Input and Output " or Hacker Rank Solution Program In C++ For Input and Output or Input and Output solution hacker rank or Hacker rank solution for c++ domain or Hacker rank solution for Input and Output sub domain or Input and Output solution in c++ of hacker rank or introduction solutions hacker rank.

Check Here:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.

Logic:- This is a very simple problem we have to just use three variable and taking a user input and store all three user input to already declare variables after that declare the fourth variable for holding all three variable SUM. below is the full explanation with example.

Explanation:- So as we already know that we have to declare three variable, so instead of declaring three variable Integer or Float we are going to declare all fourth variables Long Double, in this way we can store all types of value instead of a single type of value.

Declare Variables

long double a,b,c,sum=0;

Here we can see that three variable are declared simply declare but fourth variable sum = 0 we define that is why if any garbage value hold sum then it changes into 0 so we can get our answer simple as we want.

Taking User Input

cin>>a>>b>>c;

storing the value in all three variable by the user, now next step is Add all value holding by all three variables after adding all values store the values in another variable Define Sum. At the end print the SUM (holding sum of all three variable).

sum=a+b+c;
cout<<sum;

As we can see that our main function is Integer type that means the main function should return some value but in this case, we are not returning any value so we are returning zero here

Returning to Main Function

return 0;

Now all steps of the problem are explained clearly. I hope you got it,

Before pasting the code into the editor make sure you have chosen C++ or if C++ not worked fine then change it into C++14 an editor in the top right drop-down option.

Solution:-

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
long double a,b,c,sum=0;

cin>>a>>b>>c;

sum=a+b+c;

cout<<sum;

return 0;
}

Output:-