Executing a program written in C-Language involves a series of steps. These are :
Creating a Program :
For creating a C-Program, you can use any editor (Dev C++, Turbo C++, Code Block, Visual Studio Code, Sublime Text etc) to write the program instructions. The instructions written in the source code must follow the C programming language rules. Be sure that file should be save with extension “.c”, i.e. if your file name is “sum” then it should be save with “sum.c”.
Compiling Source Code :
You will write code in High Level Language (HLL) i.e. in English but the only language that Computer can understand is Low Level Language (LLL) i.e. Machine Language, so, we need an interpretor who will convert the HLL to LLL. This work is done by COMPILER and this process is called COMPILATION, which we can done using key ALT + F9.
Whenever we compile our code, the compiler first look for the Errors. If there are any Errors then compiler returns the List of Errors, and then you resolve these errors and recompile your code, if there are no errors then the source code is converted into object code and get stored as a file with .obj extension. Then the object code is given to the Linker. The Linker combines both the object code and the specified header file code and generates an Executable file with .exe extension.
Suppose if your file name is Sum.c then in this process it will create 2 more files i.e. Sum.obj file and Sum.exe file in the bin folder.
Run a Program :
After creating an executable file with a .exe extension, The processor can understand this .exe file content so that it can perform the task specified in the source file.
Now you can run your program by using Ctrl + F9 keys. Whenever we press Ctrl + F9, the .exe file is submitted to the CPU. On receiving .exe file, CPU performs the task according to the instructions written in the file. The result generated from the execution is placed in a window called User Screen.
See Output:
After running the program, the result is placed into User Screen. Then we just need to open the User Screen to check the result of the program execution. We use the shortcut key Alt + F5 to open the User Screen and check the result.
In conclusion, executing a C program may seem daunting at first, but with the right tools and guidance, it can be a relatively straightforward process. We’ve covered the basics of what you need to write and execute a C program, including the necessary tools and the steps involved in compiling and running your code. Whether you’re a beginner or an experienced programmer, learning C can open up a world of possibilities for developing a range of applications. With the knowledge and tips provided in this article, you can start writing and executing your own C programs with confidence, and take your programming skills to the next level. So, what are you waiting for? Start exploring the power of C programming today!