How to Run C Program in Command Prompt
Install MinGW, a simple C compiler
- Download MinGW from https://sourceforge.net/projects/mingw.
- Double-click the downloaded file and follow the on-screen instructions to prepare the installation.
- When you get to the MinGW Installation Manager window, you’ll see several packages in the upper-right panel.
- Check the boxes next to “mingw32-base” and “MinGW-GCC-g++.”
- Click the Installation menu and select Apply Changes.
- Click Apply.
Add the compiler’s path to your system environment variables
This step makes it easier to run the compiler from the command prompt, as you won’t have to enter the full path to the GCC program.
- Press the Windows key and type the environment. Click Edit the system environment variables in the search results and click the Environment Variables… button.
- Select the “Path” option under “System variables” and click Edit…
- Click New.
- Type C:\MinGW\bin and click OK. Next Click OK again then again.
Open a Command Prompt window as an administrator
To do this, press the Windows key, type cmd, right-click Command Prompt, and then select Run as Administrator.
- Once the prompt window is open, double-check that the compiler is installed properly (and that the environment variables are set) by running the command GCC -- version at the prompt.
- If you already had a command prompt window open, close it and open another so the path you added
Use the cd command to go to the directory where your C program is saved
Run the GCC command to compile your C program.
The syntax you’ll use is GCC filename. c -o filename.exe. This compiles the program and makes it executable.
- Replace filename. c with the name of the file containing your C code, and filename.exe with the name you want to give the compiled program as well as make sure you give the compiled program a name that ends with .exe.
- The -o flag specifies the output file.
Type the name of your new program and press Enter
Number Programs to show how to Run C Program in Command Prompt
In the images, we have executed the number programs and shown you the screenshots. However, there are three programs: Factorial, Fibonacci, and difference series.
You can also refer to this outbound link
The Book Of Five Rings Summary
How to Talk to Anyone by Leil Lowndes
Jonathan Livingston Seagull Book Summary
Your Brain on PORN Book Summary by Gary Wilson
THE IMMORTALS OF MELUHA By Amish Tripathi full summary
File Handling implementation in C language
What is do-while loop in C Programming ? Loops
What are loops in C programming?For,While,Do-While