Monday, 14 March 2016

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

Adding and Printing

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.

Submit your solution here:- Click here


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:-

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment