Below is a program to print message with an inputted name with explanation in C language.
#include < stdio.h >
int main( )
char name ;
printf(” Enter your name : “) ;
printf(“\n Hello !!: %s”,name) ;
return 0 ;
Enter your name : jiwanjot
Hello !!: jiwanjot
Here’s a step-by-step explanation of the program:
#include <stdio.h>statement is a preprocessor directive that includes the standard input/output library.
int main()function is the starting point of the program. It returns an integer value and contains the program’s instructions.
- Inside the
main()function, we declare a character array
nameof size 25, which is used to store the inputted name.
printf()function displays a message to the user, prompting them to enter their name.
scanf()function reads the user input from the keyboard and stores it in the
- Finally, the second
printf()function displays a welcome message to the user, using the inputted name.
return 0;statement indicates that the program has finished executing.
To run the program, compile and execute it using a C compiler, such as GCC.
If you want to more information about C programming, then join our course.