Hackerrank Solution For Day 0: Hello, World

Problem:- Write a Hackerrank Solution For Day 0: Hello, World or Hacker Rank Solution Program In C++ For " Day 0: Hello, World." or Hackerrank solution for 30 Days of Code Challenges. 

Hackerrank Solution For Day 0: Hello, World

Logic:- This is a very simple program in any programming language or we can say that this is a first program that we execute the first time in the learning time of any language like C language, C++ language, Java language and Python language. So basically in this program, we have to print a string Hello, World. Here we will choose C++ Domain for coding and find all solution of 30 Days Challenges Series. So in C++ " cout<< " is used for print anything in the terminal so we will put the string " Hello, World. " in double quotes, Below is an explanation of program step by step.


string input_string;

input_string is a variable which stores the string " Hello, World. " in string format. We know that we can store string or character also, there is a no limitation. A string may contain many characters there is no limitation. 

getline(cin, input_string)

getline is used for store multiple strings with included space and next-line. getline reads line by line and store the string in the variable and cin is used for storing anything in C++.

cout << "Hello, World." << endl;

as I already mention that cout is stream output and printf(" ") in C is a function. So for printing any string and number we just put the string between double quotes.

Below is the Solution of Hackerrank 30 challenges series or day 0 solution in Hackerrank. You can copy The Color Code and paste it into Hackerrank Editor or you can copy the full code and paste into Hackerrank Editor. You can direct click below link and it will redirect to problem page you have to just log in and run and test the code.

Submit Your Solution Here:- Click Here


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

int main() {
    // Declare a variable named 'input_string' to hold our input.
    string input_string; 
    // Read a full line of input from stdin (cin) and save it to our variable, input_string.
    getline(cin, input_string); 
    // Print a string literal saying "Hello, World." to stdout using cout.
    cout << "Hello, World." << endl;

    // TODO: Write a line of code here that prints the contents of input_string to stdout.
    return 0;


Hackerrank Solution For Day 0: Hello, World

You May Also Like:-

No comments:

Post a Comment