First thing you need to understand is that computer (Machine) can only understand Machine language (Stream of 0s and 1s). In order to convert your C program source code to Machine code, you need to compile it. Compiler is the one, which converts source code to Machine code. In simple words you can say that a compiler converts human readable code to a machine readable format.
Install Turbo C++: Step by Step Guide
Download link: Download Turbo C++ for Windows
Step 1: Locate the TC.exe file and open it. You will find it at location C:\TC\BIN\.
Step 2: File > New (as shown in above picture) and then write your C program
#include<stdio.h> int main() { printf("hello World!"); return 0; }
Step 3: Save the program using F2 (OR file > Save), remember the extension should be “.c”. In the below screenshot I have given the name as helloworld.c.
Step 4: Compile the program using Alt + F9 OR Compile > Compile (as shown in the below screenshot).
Step 5: Press Ctrl + F9 to Run (or select Run > Run in menu bar ) the C program.
Step 6: Alt+F5 to view the output of the program at the output screen.
Compile and Run C program using gcc compiler
We have seen the steps to compile and execute a C program using Turbo C++. We can also do the same using gcc compiler. The steps are as follows:
Source code Helloworld.c (file should always be saved with .c extension)
# include<stdio.h> int main() { puts ("hello World"); return 0; }
Compile it (it is basically converting a helloworld.c file to a helloworld file)
>gcc helloworld.c –o helloworld >
The generated file would be helloworld.exe if you are compiling on windows.
Run the compiled program
Once you give the above command, a .exe file would have been created if you are on windows then type the following command to run the source code.
For Windows
>helloworld
For Mac and Linux OS
>./helloworld
gcc compiler took the human readable format (helloworld.c file) and converted into a machine code for Windows, Linux and Mac OS X.
Nadeera says
Hi,
This is very simple tutorial that anyone can get basic idea related to “turbo c”. So thank you very much for your valuable service.
s.sanil gupta says
Thank you very much for posting these things.The beginners get a good idea about turbo compiler.
vishal singh says
I WANT TO KNEW HOW TO CONVERT C++ FILE INTO EXE.
vijay kumar says
how to convert c program into a setup so that it can be run on
any computer
Social Ahmed says
I would like to thank. I am pleased to know all that things, which we want about c programming. It’s a very helpful and useful to us