3/22/2017

Day 0: Hello, World Hackerrank Solution | 30 Days of Code

Problem Statement- day 0: hello, world hackerrank solution or hacker rank website solution with a problem statement in the C programming language. This is the first programming problem of 30 days of code of hackerrank website. Hello, world is the first program ever written in any programming language.

Day 0 Hackerrank Solution

Day 0 Problem 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.

Hello, World Hackerrank Solution Explanation


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.

Updated Solutions: Day 1 Data Types Solution in C, C++, and Java Programming Language

Submit Your Solution Here:- Click Here

Hello, World Day 0 Hackerrank Solution


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

cout<<input_string;


return 0;

}

Day 0: Hello, World Code Output


Day 0: Hello, World

Similar on 30 Days of Code


No comments:

Post a Comment