How to install Turbo C++: Compile and Run a C Program

How to install Turbo C++: Compile and Run a C Program

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
Step 1: Locate the TC_DOS.exe file and open it. You will find it at location C:\TurboC++.
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.

Post a Comment

Previous Post Next Post