Say Hello, World! with C++ - Hacker Rank Solution

In this Tutorial we will be solving Say Hello, World! With C++ - Hacker Rank Solution. Say Hello, World! with C++ - Hacker Rank Solution

Say Hello, World! with C++ - Hacker Rank Solution 

You can't call yourself a real programmer until you know how to code in C++. C++ is one of the oldest and most popular coding language. It is very essential language to learn if you are interested in competitive coding.

So, from today we are starting C++ Hacker Rank Solution series in which we will be providing solutions of hackerrank problems and will discuss about different topics of C++. 

Say Hello, World! with C++ - Hacker Rank Solution


Objective 

This is a simple challenge to help you practice printing to stdout. You may also want to complete Solve Me First in C++ before attempting this challenge.

We're starting out by printing the most famous computing phrase of all time! in the editor below, use either printf or cout to print the string Hello, World! to stdout.

Input Format 

We do not need to read any input in this challenge.

Output Format

Print the String Hello, World! to stdout.

Sample Output 

Hello, World!

Solution - Say Hello, World! in C++

#include <iostream>
#include<stdio.h>
using namespace std;

int main(){
    cout<<"Hello, World!";
    return 0;
}
Say Hello, World! with C++ - Hacker Rank Solution
Say Hello, World! with C++ - Hacker Rank Solution 

Say Hello, World! with C++ - Hacker Rank Solution
Say Hello, World! with C++ - Result


Explanation

Here we have used cout instead of printf because most popular command form is cout. It has the following basic form:

cout << value_to_be_printed << Value_to_print;

Any number of values can be printed using one command as shown.

The printf command comes from C language. It accepts an optional format specification and a list of variables. Two examples for printing a String are:

printf ("%s", string) ; printf(string) ;

Note that neither methods add a new line. It only prints what you tell it to.

Conclusion

So, Coders today we have learn how to use cout and write Hello, World! program using it. The above problem is generated by Hacker Rank but the Solution is provided by Sloth Coders. If you have any doubt regarding the problem ( Hello, World! in C++), feel free to contact in the Comment Section.

Don't forget to Share this post with your friends and Subscribe to our Blog to receive daily updates related of coding.

Happy Coding!!

A Sloth Who love to Code.

Sloth Coders is a Learning Platform for Coders, Programmers and Developers to learn from the basics to advance of Coding of different langauges(python, Java, Javascript and many more).

Post a Comment