Hello World in C - Hacker Rank Solution

In today's post we are going to solve Hello World Hacker Rank Problem in C. This is one of the basic and easiest program in C. In this we mainly have

Happy new year year guys. It's not just the beginning of 2021 but we are also welcoming our C Hacker Rank Solution series. In this series we will mainly providing and explaining different concepts of C by using Hacker Rank problems.

In today's post we are going to solve Hello World Hacker Rank Problem in C. This is one of the basic and easiest program in C. In this we mainly have to show output on the display.

So, without wasting any more time let's jump to our topic.

Hello World in C Hacker Rank Solution

Objective 

In this challenge, we will learn some basic concepts of C that will get you started with the language. You will need to use the same syntax to read input and write output in many C challenges. As you work these problems, review the code stubs to learn about reading from stdin and writing to stdout.

Task 

This challenge requires you to print Hello, World! on a single line, and then print the already provided input string to stdout.

If you are not familiar with C, you may want to read about the printf() command.

Example 

s = "Life is beautiful"

The required output is:

Hello, World!
Life is beautiful

Function Description 

Complete the main() function below.

The main() function has the following input:

string s: a string

Prints

*two strings: * "Hello, World!" on one line and the input string on the next line.

Input Format 

There is one line of text, s.

Sample Input 0

Welcome to C programming.

Sample Output 0

Hello, World!
Welcome to C programming.

Solution - Hello, World in C

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() 
{
	
    char s[100];
    scanf("%[^\n]%*c", &s);
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */    
    printf("Hello, World!\n");
    printf(s);
    return 0;
}
Hello World C Hackerrank solution
Hello World C Hackerrank solution
Hello World C Hackerrank solution
Hello World C - Result


Conclusion 

So, coders today you have learned about basic hello world program in C. Now you can solve such kind of Hello World Hacker Rank problem by your own.

If you still have any doubt regarding the problem or the topic, feel free to contact in the comment section.

I will meet you in next post till then stay healthy, stay safe.

Happy Coding!!

A Sloth Who loves to Code

Disclaimer: The above problem (Hello World in C) is generated by HackerRank but the solution is provided by Sloth Coders.

Sloth Coders is a Learning Platform for Coders, Programmers and Developers to learn from the basics to advance of Coding of different langauges(python, Java, Javascript and many more).

Post a Comment