In this HackerRank Hello World! in c programming problem, it 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.

To print in C, you can use the printf(a), function which is declared in the stdio.h library. The syntax of the printf statement is printf("format string",argument_list); To print a string, S, the statement would look like this: printf("%s", s);. Here %s is the format specifier for a null-terminated array of characters.


HackerRank Hello World! in C programming solution


HackerRank Hello World! in C Programming solution.

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

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


Second solution

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


int main ()
{
    char s[100];
    fgets(s, sizeof(s), stdin);
    printf("Hello, World!\n%s", s);
    
    return 0;
}


Here in the above code, we define an array of character type and then we take input using scanf() function and store in the array. and then we print the Hello World message on the output screen using the printf() function and also print the value of array s.