DEV Community

Cover image for Day 0: Hello, World - 30 days of code Hackerrank
Aayushi Sharma
Aayushi Sharma

Posted on • Updated on

Day 0: Hello, World - 30 days of code Hackerrank

We are going to solve HackerRank “30 Days of Code” programing problem day 0 hello world HackerRank solution in C++, Python and JavaScript language with complete code.

Task

To complete this challenge, you must save a line of input from stdin to a variable, print Hello, World. on a single line, and finally print the value of your variable on a second line.

30 days of Code aayushi-droid

Explanation

On the first line, we print the string literal Hello, World.. On the second line, we print the contents of the variable which, for this sample case, happens to be Welcome to 30 Days of Code!. If you do not print the variable's contents to stdout, you will not pass the hidden test case.

Hello World HackerRank Solution in Python

# Read a full line of input from stdin and save it to our dynamically typed variable, input_string.
input_string = input()

# Print a string literal saying "Hello, World." to stdout.
print('Hello, World.')
# TODO: Write a line of code here that prints the contents of input_string to stdout.
print(input_string)

Hello World HackerRank Solution in C++

#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;
}

Hello World HackerRank Solution in JavaScript

function processData(inputString) {
    // This line of code prints the first line of output
    console.log("Hello, World.");
    // Write the second line of output that prints the contents of 'inputString' here.
    console.log(inputString);
}


process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
   processData(_input);
});

Discussion (0)