C

Installing Turbo C++: Compiling And Running A C Program

The first thing you should know is that a computer (Machine) can only understand Machine language (Stream of 0s and 1s). You must compile your C program source code in order to convert it to Machine code. The compiler is the software that converts source code to machine code. In layman’s terms, a compiler converts human-readable code to machine-readable code.

Turbo C++ Installation: A Step-by-Step Guide

Step 1: Locate and launch the TC.exe file. It can be found at location C:TCBIN.
Step 2: File > New (as shown in the preceding image), and then write your C program

#include<stdio.h>
int main()
{
       printf("hello World!");
       return 0;
}

Step 3: Save the program by pressing F2 (OR file > Save); the extension should be “.c.” In the screenshot below, I’ve named the file helloworld.c.
Step 4: Compile the program by pressing Alt + F9 or selecting Compile > Compile (as shown in the below screenshot).
Step 5: Press Ctrl + F9 to run the C program (or select Run > Run in the menu bar).
Step 6: Press Alt+F5 to view the program’s output on the output screen.

Compile and run a C program with the gcc compiler.

We’ve gone over how to compile and run a C program with Turbo C++. We can also do the same thing with the gcc compiler. The procedure is as follows:
Helloworld.c is the source code (file should always be saved with .c extension)

# include<stdio.h>
int main()
{
         puts ("hello World");
         return 0;
}

Put it together (it is basically converting a helloworld.c file to a helloworld file)

>gcc  helloworld.c  o  helloworld
>

If you are compiling on Windows, the generated file will be helloworld.exe.
Start the compiled program.
If you are using Windows, a.exe file will be created after you run the above command. To run the source code, type the following command.
For Microsoft Windows

>helloworld

The gcc compiler for Mac and Linux OS converted the human-readable format (helloworld.c file) into machine code for Windows, Linux, and Mac OS X.

>./helloworld

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button