How to Run C Program in Command Prompt Using GCC

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.

Gcc Compiler

So first check whether your computer has gcc installed or not.

  1. Open CMD (Command Prompt ).
  2. Type
    gcc -v
    Gcc compiler install

    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.

    and hit Enter

  3. If it prompts that “gcc not recognized“. Then follow “Install gcc in windows” .
  4. If already installed then go directly to “Run C Program in Command Prompt Using gcc” Section Below.

Install GCC in windows

Open SourceForge TDM-GCC MinGW Compiler.

Run C Program

Download GCC compiler for windows by clicking the download button.

Run gcc compiler setup to install gcc compiler.

run gcc in cmd

How to Run C Program in Command Prompt Using gcc

Run C Program in Command Prompt

gcc compiler installer windows

Open command prompt and Type

gcc -v

and hit Enter. This time you will see something like this as stated in the picture.

Run C Program in Command Prompt Using gcc

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.

OR

you can press Shift + right click on the free space of the window containing your program file. Choose Open command window here.

Run C Program in cmd

Now type

 gcc filename.c

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

How to Run C Program in cmd Using gcc

To run the program for output, Type

 a.exe

and press Enter.

how to run c program in ubuntu

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *