C++ Basic question on Hackerrank - Algomentor

Say "Hello, World!" With C++


hackerrank rank practice question part 1



Hi, welcome to the series of data structure and algorithm made easy
This is the Hackerrank Que click on this link to get the question.

To solve this question we all need to know basics of C++ like how to print something on the screen in C++ if we are using the iostream library we can use function cout but if we using cstudio we need to print using printf function.

Here is the code of this question.

#include <iostream>
#include <cstdio>
using namespace std;

int main() {
    printf("Hello, World!");
    return 0;
}

So all we do is we just use printf function to print "Hello, World!" you can also try This in the HackerRank.


Input and Output



This is the Hackerrank Que click on this link to get the question.

In this question, you need to take input of three integers a,b,c, and then sum up those integers and then print it for this we use cin function of iostream.  

Here is the code for the question.

#include <iostream>
using namespace std;

int main() {
    int a,b,c,d;
    cin>>a>>b>>c;
    d=a+b+c;
    cout<<d;
    return 0;
}

The code is already self-explanatory we first declare the integers and the take input using cin function and we store sum of these integers in another variable name d and then we just print d. using cout function.

I hope you like my editorial for these question although these are very easy but don't worry slowly-slowly we do difficult question for these also we do question java, Python, Problem Solving also so please do visit us regularly.

As we update about our blog on our social handle so please do follow them also. And if you like our blog very much you can take an Email subscription which is totally free of cost.

Thank you very much for reading our post please do share with your friends 😀.

Hi if you want to write a post on our website then please check this article on How to do a guest post.

Post a Comment

1 Comments