Home30 Days Of CodeHackerrank Day 0 : Hello World 30 days of code solution

Hackerrank Day 0 : Hello World 30 days of code solution

In this HackerRank Day 0 Hello World 30 days of code problem, we need to develop a program that prints the Hello, World message on the output screen.

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.

You’ve got this!

Note: The instructions are Java-based, but we support submissions in many popular languages. You can switch languages using the drop-down menu above your editor, and the inputString variable may be written differently depending on the best-practice conventions of your submission language.

Input Format

A single line of text denoting inputString (the variable whose contents must be printed).

Output Format

Print Hello, World. on the first line, and the contents of  inputString  on the second line.

Sample Input

Welcome to 30 Days of Code!

Sample Output

Hello, World. 
Welcome to 30 Days of Code!

Explanation

On the first line, we print the string literal Hello, World.. On the second line, we print the contents of the  inputString  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.

How to Use this Solution

Visit to the hacker rank 30 days of code challenge page and open day 0 “hello world” problem, in the below solution code there is a code between /* solution starts from here */ and /* solution ends here */ just copy the code and paste it to the hacker rank editor and click on submit button.

Hello World HackerRank Solution in C

#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", inputString);
   return 0;
}

Hello World HackerRank Solution in C ++

#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 << endl; 
   return 0;
}

Hello World HackerRank Solution in JAVA

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.");
      
      // Write the second line of output
      System.out.println(inputString);
   }
}

Hello World HackerRank Solution in Python 3

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

function processData(inputString) {
    // Your first line of output goes here
    process.stdout.write("Hello, World." + "\n"); 
    
    // Write the second line of output
    process.stdout.write(inputString);
} 
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});
process.stdin.on("end", function () {
   processData(_input);
});

NEXT : Hackerrank Day 1 : Data types

30 Days of Code HackerRank Solutions List – Day 0 to Day 29


Read More –

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

- Advertisment -

Categories