In this HackerRank Day 0: Hello, World problem solution 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.


HackerRank Day 0: Hello, World. problem solution

Problem solution in Python programming.

inputString = input() # get a line of input from stdin and save it to our variable

# Your first line of output goes here
print('Hello, World.')

# Write the second line of output
print(inputString)



Problem solution in Java programming.

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {
   public static void main(String[] args) {
      Scanner scan = new Scanner(System.in); // use the Scanner class to read from stdin
      String inputString = scan.nextLine(); // read a line of input and save it to a variable
      scan.close(); // close the scanner
      
      // Your first line of output goes here
      System.out.println("Hello, World.");
      
      System.out.println(inputString);
   }
}




Problem solution in C++ programming.

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

int main() {
   string inputString; // declare a variable to hold our input
   getline(cin, inputString); // get a line of input from cin and save it to our variable
  
   // Your first line of output goes here
   cout << "Hello, World." << endl;
   cout << inputString;
   // Write the second line of output

   return 0;
}



Problem solution in C programming.

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
   char inputString[105]; // declare a variable to hold our input
   scanf("%[^\n]", inputString); // get a line of input from stdin and save it to our variable
  
   // Your first line of output goes here
   printf("Hello, World.\n");

   // Write the second line of output
   printf("%s\n", inputString);
    
   return 0;
}



Problem solution in JavaScript programming.

function processData(inputString) {
    // Your first line of output goes here
    process.stdout.write("Hello, World.");
    
    // Write the second line of output
    process.stdout.write("\n" + inputString);
} 


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

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