How to execute C Program on local computer using IDE ?


We need a C compiler to run (execute) a program written in the C programming language, In this tutorial, we will learn about Environment Setup using IDE (Integrated Development Environment) through which we will be able to easily execute our C and C++ programs. In this tutorial, we'll install the DEV C++ tool on our computer and learn how to set up the DEV C++ environment variables to run C programs on the local computer.

First, let's understand some important headings.

What is a C Compiler?

In the previous C programming tutorial, we learned that C programming is a high-level language that uses English words, symbols, and digits. However, to make the computer understand, we need to convert high-level code into low-level binary form. A compiler is used to convert C programs from high-level to low-level language.

In simple terms, when you write a program in C using English words, digits, or symbols, the computer understands it in binary code (0s and 1s). To make the computer understand this code, we use a compiler to convert the program into binary form (01 form) so that the computer machine can take action on it.

The C compiler acts as a mediator between the user and the computer machine, making it essential for both the user and the computer to understand each other. The compiler plays an important role in converting C programs into binary code so that the computer machine can understand them.

There are many compilers available on the internet for compiling C programs that can be used on Windows. Some examples include GCC compiler, Clang, Digital Mars, Ritchie C Compiler, CCS C Compiler, etc.

Now, let's install DEV C++ and learn how to compile and execute a C program.

Execute C program on local computer using DEV C++ IDE(Integrated Development Environment)

DEV C++ is a free IDE that can be used to compile and run C and C++ programs. DEV C++ works on both Windows and Linux operating systems. The DEV C++ tool uses the GCC compiler to compile and execute C and C++ programs. Besides the GCC compiler, you can also use other C compilers, but here we will learn how to run C programs using the GCC compiler.

To set up DEV C++, follow these steps:

Step 1- Download DEV C++ from the following links:

https://bloodshed-dev-c.en.softonic.com/download

https://www.bloodshed.net/

If you cannot find DEV C++ on these links, you can directly search for DEV C++ on Google and download it.

Step 2-  Once the DEV C++ IDE exe file is downloaded, install it by clicking on the downloaded file.

Step3-  In the next step, you need to select the destination where DEV C++ will be installed. This destination path will also be used to set up environment variables. Install DEV C++ on the destination path, for example, "C:\Dev-Cpp". This will be helpful when we set up the environment path.

Install Dev C++ tool

Step 4- After installing DEV C++, we need to set up environment variables. To do this, click on "My Computer" -> "Properties" -> "Advanced system settings" -> and then click on "Environment Variables."

If you cannot find the "Environment Variables" option, another way is to go to your Control Panel, then "System and Security" -> "System" -> "Advanced system settings." If you still cannot find "Advanced system settings," search for it using the search bar in the Control Panel.

Now, click on the "Environment Variables" option.

Enviroment variable setup for C program execution

Step 5-  This step is very important. If you have already set up environment variables for Java, you'll see environment variables there too. Now, you need to set up the environment variable for DEV C++. In the first field, give the variable name as "PATH," and in the second textbox, provide the variable value,where you installed DEV C++.

Variable name: PATH

Variable Value: C:\Dev-Cpp

Now, click "OK" to complete the setup.

Enviroment variable Path setup for C program

Step 6-  Now you have to open DEV C++. Now go to File -> new -> project and select Console and C project. You can name the project anything or keep it as Project 1.

Run c program using IDE on local computer

Step 7 – In this step, you need to write a simple C program:


#include <stdio.h>
#include <stdlib.h>

void main() {

printf("This is my first Program");

}

C program

There will be many icons given in the window header above, by moving the mouse pointer on them you will know which icon is used for what.

Now save this program.

While saving, please give the name of your program along with the .c extension.

For example, we take the name of the program as myprogram and then we save it like this.

myprogram.c

save c program

save c program

Step 8 – After saving the C program, it needs to be compiled and run to check for any errors and execute it. At the top, you'll find an "Execute" option. Clicking on it will give you the option to "Compile & Run." Click on it, and your program will be compiled first, then run, and you'll see the output on a prompt.

Run c program and output on console

,You can execute any number of C and C++ programs by following these steps on your local computer. This process is also referred to as a local code runner.


Please Share

Recommended Posts:-