Run and Compile a C program on Windows 10 using gcc Compiler (MinGW). Make sure you have installed mingw on your system. Write a C program that takes input from the user then displays the greeting message. This is a step by step tutorial so fire up your favorite text editor and code along. I am giong to use my Sublime Text Editor on my old Windows 10 computer.

  1. First create a c file like greet_user.c
  2. Include stdio.h header file in your c program file
  3. Prompt the user to enter her/his name
  4. Greet the user with function
  5. Save the file
  6. Compile with gcc compiler and run the exe package..

C stdio.h header

#include <stdio.h> 

Greet User Function in C

void greet_user()	 
  char name[10]; 	 
  printf("\n Enter Your Name: ");	 
  scanf("%s", name);	 
  printf("\nHello, %s \nHow are you?",name);	 

Call Greet User Function in Main Function

int main() 	 
  return 0; 	 

Compile C code/program with GCC

gcc greet_user.c -o greet

Run Compiled C Program with CMD/Command Prompt


Complete C Greet User Program Code

/* First we need to include (Input/Output) header file */
#include <stdio.h> 

/*This is global function means this function can be access within whole page*/

 /*void means large empty space it does not return any value*/
void get_Name()
	{  	/*function block starts here*/
	   char name[10]; /*This is character data type array*/
	/*printf is use for printing a message on output screen*/

          printf("\nEnter Your Name: ");/* and here \n means newline */
 /*scanf keyword is used to take input through keyboard (user). */

         scanf("%s", name);	

/*%s is placeholder of array character data type*/		

   	printf("\nHello, %s \nHow are you?",name);
	/*function block ends here*/

/*Main function have integer data type it means we must return any numeric value before ending the block of the function*/

int main() /* then create main function*/
	/*Within main function write our Statements*/
	/*Every Statement must be ends with semicolon ; */
	/*Every function must be call in main function area*/

	/*So, now, here I'm calling get_Name() method or function*/

	 printf("\nThis is First Program to take input through user      and then display.\n"); 

	return 0; /*here must return any numerical*/

To run and compile the C program. First write gcc word then filename with extension
AND “-o” is use for providing a short name of that file.