Monday, 14 March 2016

Hacker Rank Solution For Input and Output

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,

Also Check- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

Copy the full solution or colored code and paste into the hacker rank editor and click to Run Code if the code runs successfully then click to Submit Code. 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

Tip:- Before copy the program I recommended please read this full article, this will help you to build your own logic. 

If you have any query feel free to share with me, and if you like my work please share, comments and subscribe for our new and latest post related to programming this will help you update all about new post this Article.


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

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




    return 0;


No comments:
Write comments

Recommended Posts × +