GupShup Study
C - basic program and program structure
Neeraj Yadav

C - basic program and program structure

10-Jul-2016 | | Total View : 1128 |

In the previous tutorial we learn about basic introduction of C language and how to setup Turboo C++ in PC. Hope you like our previous articles. If you miss those articles then please click on below link to read them first.

1 - C language Tutorials - What is C language? basic information

2 - How to install and Run C language program in PC - Support Full Screen

C - Program structure

In this part of tutorial we will learn about C - Program structure and how to write a sample code for C language. We are going to learn a simple “Hello World” C program in this section.  let us look at a bare minimum C program structure - 

Before we begin with our first C program do remember the some rules that are applicable to all C programs.

C program basically consists of the following parts:

  1. Preprocessor Commands
  2. Functions
  4. Variables
  5. Statements & Expressions

To write the first c program, open the C console and write the following code:

#include <stdio.h>  

#include <conio.h>  

void main() {  

/* my first program in C */

printf("Hello GupShupStudy");   



Let us take a look at the various parts of the above program −

  • The first line of the program #include <stdio.h> is a preprocessor command, which tells a C compiler to include stdio.h file before going to actual compilation.

#include <stdio.h> includes the standard input output library functions. The printf() function is defined in stdio.h .

#include <conio.h> includes the console input output library functions. The getch() function is defined in conio.h file.

  • The next line void main() is the main function where the program execution begins.

  • The next line /* my first program in C */ will be ignored by the compiler and it has been put to add additional comments in the program. So such lines are called comments in the program.

  • The next line printf(...) is another function available in C which causes the message "Hello, World!" to be displayed on the screen.

  • getch() The getch() function asks for a single character. Until you press any key, it blocks the screen.

How to compile and Execute the C program - 

1 - To compile the program press + keys. if there are any error on program then it will be shown.

2 - To Execute (Run) the program press + keys. and the Output is -

Note: use "clrscr()" after the Main Function to clear the output screen. this will clear previous output everytime you run a program.

Without "Clrscr()"

With "Clrscr()"


You can view the user screen any time by pressing the + keys.

Save the Code -

To save the program press  key, or go to File and Click on Save icon.

"Don't forget to save file name with ".CPP" extension.

Hope you like this tutorial, Please share your thoughts by comment section below.

Please Share with your friends"


Share With Friends :  

No any Comment yet!