# How to Compile a C program using Turbo C++?

In the previous article, you learned how to install a Turbo C++ compiler on a windows system. After installation you must write your first C program ,and compile it. In this article you will learn to compile your first C program.

Contents

To start writing your first C program using Turbo C++ compiler follow the steps given below.

#### Open Turbo C++ Initial Screen

The first step is to open the Turbo C++ initial screen which is shown below. You can do this after installation either by clicking the desktop icon or click the Turbo C++ icon in start menu. The screen look like the following.

#### Start the Turbo C++ Compiler

The next step is to start the Turbo C++ compiler by clicking the “Start Turbo C++” compiler. You will see the compiler window shown below.

Before you write your program, make sure that the directories are correctly configured for the compiler. Go to Options > Click Directories in the Menu Bar. The following screen will appear, so you must verify the directories given here.

The directories must exist with all the required files and path to directories must be correct. You must verify this manually. If necessary, change the directories to where the Turbo C++ files exists.

#### Create a New Source File (prog.C)

By default, the program name is noname.cpp, but we want C source file. Go to File menu > Click Save as and in the Save File As box, type the name of the C source file.

Prog.C

Now, you can start writing your C program code. For this example, we will write the ‘Hello World’ program.

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

### Compile the Program

There is two ways to compile a program in Turbo C++.

1. Press Alt-F9 (as instructed in the status bar of Turbo C++)
2. Go to Compile tab of Menu bar and press Compile or Build All.

The compiler will finish compilation with no error or with some warnings. If an error is encountered, then the compilation is aborted and the problem line or lines are highlighted with error description.

In the above program, we purposly omitted semi-colon (;) at the end of the C statement. This resulted in an error. The program indicate the line no, then name of the program and the error description.

### Execute the Program

The program is created, you can run and test the output. To run the program, go to Run menu and click Run or press Ctrl + F9.The output of the error-free compiled program is given below.

### References

• Balagurusamy, E. 2000. Programming in ANSI C. Tata McGraw-Hill Education,.
• Brian W. Kernighan, Dennis M. Ritchie. 1988. C Programming Language, 2nd Edition. Prentice Hall
• Kanetkar, Yashavant. 20 November 2002. Let us C. Bpb Publications

Bestseller

#### The C Programming Language – 2nd Edition

The Second Edition of The C Programming Language The book enumerates the concepts related to C Programming language, as prescribed by ANSI standard. The book elaborates on the basics of procedure oriented programming and the fundamentals of writing C codes. It goes on to cover aspects like functions and loops, learning which will help novice programmers to code elementary level codes properly. Solved and unsolved questions have been provided to help programmers develop an expertise in writing C codes flawlessly.