• Home
  • Simple C Program

Simple C Program

Here is a simple C program that prompts the user to enter their name and then prints a personalized greeting:

#include <stdio.h>

int main()
char name[20];

printf("Enter your name: ");
scanf("%s", name);

printf("Hello, %s!\n", name);

return 0;

This program includes the standard input/output library (stdio.h) and defines a main function, which is the entry point of the program. It then declares a character array called “name” that will be used to store the user’s name.

The program then uses the printf function to print a prompt asking the user to enter their name, and the scanf function to read the user’s input and store it in the “name” array. Finally, the program uses printf again to print a personalized greeting using the user’s name.

This is a very basic example of a C program, but it demonstrates some of the basic features of the language, such as input/output functions, variables, and data types.