C First Program

C First Program

In the previous lesson we learned how to setup environment for C. Now, we will see how to run C first program.  It’s quite easy. Let’s begin with launching Turbo C and run C first program.

Go to Start > Turbo C

Open Turbo C and open a new project,

File > New

Firstly, save it and give any name with extension c. Here, we have given the name Study1.c,

Now, let’s add a demo program

Let’s work on our first C program,



It is the preprocessor and the first word read by the compiler


It is the header file.

int main()

main() function with return type int.

Used to  print formatted string to stdout. Standard output is stdout.


Terminates the function execution and the return statement returns the control to the calling function.

When you will run the above program, you won’t get an output in Turbo C, but the program runs correctly. To allow the output to be visible on the screen, remove the return statement and add return type to the main() function as shown below, with getch() method.

Also, add <conio.h> header file and getch() for output to be visible in Turbo C++. The MS-DOS compiler use the <conio.h> header file to show console input/output.

getch()  is used to read a character from screen and added just before the program ends. It is a predefined function in <conio.h> header file. To clear the screen, you can also add clrscr(); just after the declaration.

We’re using the <conio.h> header file and getch() to show output on Turbo C, which is our MS-DOS compiler.

Here’s or final C program,

Here’s our C program on Turbo C compiler,

For output, press Ctrl+F9.

The following output is visible,

In this lesson we learned how to tun first C program in Turbo C. Similarly, create a new file in Turbo C, write C code in it and run it as shown above,

Setup Environment for C
Tokens in C Programming
Studyopedia Editorial Staff
Studyopedia Editorial Staff

We work to create free tutorials for all.

No Comments

Post A Comment