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


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). 

Adding and Printing


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.

Submit your solution here:- Click here


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

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




    return 0;


Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

1 comment:

  1. the jaintor at hacker high school is insanely efficient.by the end of each day all of the waste from the trash cans in the schooel has beeb shifted into plastic bags which can carry waste weighing between 1.01 pounds and 3.00 pounds.all of the plastic bags must be dumped into the trash cans outside the school.the jaintor can carry at most 3.00 pounds at once.one trip is describe as selecting a few bags which together don't weight more than 3.00 pounds, dumping them in the out door trash can and returning to the school .the jaintor wants to make minimum number of trips to the outdoor trash can.given the number of plastic bags ,n,and the weight of each bag, determine the minimum number of trips if the jaintor selects bags int way .for this c program