First C Program
Before we study basic building blocks of the C programming language, let us look a bare minimum C program structure so that we can take it as a reference in upcoming chapters.
How to write First 'Hello World' Program in C
To write the first c program, open the Tarbo C and write the following code
printf("Hello World, This is my first program in C");
Hello World, This is my first program in C
Explanation of above program
Let us c
#include - It includes the standard input output library functions. The printf() function is defined in stdio.h
#include -includes the console input output library functions. The getch() function is defined in conio.h file.
void main() - The main() function is the entry point of every program in c language. The void keyword specifies that it returns no value.
printf() -The printf() function is used to print data on the console.
getch() - The getch() function asks for a single character. Until you press any key, it blocks the screen.
How Compile & Execute C Program:
Now click on the compile menu then compile sub menu to compile the c program.
Then click on the run menu then run sub menu to run the c program.
Note : press ctrl+f9 keys compile and run the program directly
Clear screen by using clrscr() function
If you run the c program many times, it will append the output in previous output. But, you can call clrscr() function to clear the screen. So it will be better for you to call clrscr() function after the main method as given below:
What next ?
C Programming Tutorial