How to Run C Program in Command Prompt Using GCC – In this tutorial we will discuss step by step approach on how to run c program in command prompt/cmd in windows.
To run C program in command prompt using gcc, you will need GCC compiler.
So first check whether your computer has gcc installed or not.
- Open CMD (Command Prompt ).
- Type1gcc -v
and hit Enter
- If it prompts that “gcc not recognized“. Then follow “Install gcc in windows” .
- If already installed then go directly to “Run C Program in Command Prompt Using gcc” Section Below.
Install GCC in windows
Download GCC compiler for windows by clicking the download button.
Run gcc compiler setup to install gcc compiler.
Open command prompt and Type
and hit Enter. This time you will see something like this as stated in the picture.
You have successfully installed GCC Compiler in windows.
Run C Program in Command Prompt Using GCC
Navigate to the directory where your program file is located. Use C: or F: or D: to change drive. And “cd” to change directory.
you can press Shift + right click on the free space of the window containing your program file. Choose Open command window here.
in the command prompt. If your program doesn’t contain any error then the cmd will show nothing. Otherwise errors will be displayed.
Once your program is error free. Compile using gcc filename.c
To run the program for output, Type
and press Enter.