Your Frist C Program
After successfully installed turbo c++ or any other c compiler then it’s time to create and execute your first c program. Currently, we create c programs in Windows operating system.
C program is consists of the following components
- Preprocessor Commands
In c programming tutorial first step is how to write your first c program in turbo c++.
For create your frist program open c console and type the below code.
/* My First Hello World Program */
printf(" Hello World ");
C Program Explanation
- #include<stdio.h> is standard input output library. The printf() and scanf() functions are defined in this library.
- #include<conio.h> is console input output library. The clrscr() and getch() functions are defined in this library.
- The void main() is the main() function of the c program. It is also known as an entry point of a program because program starts executing from this main() function. In the main function, void specifies that the main function does not return any value. In place of void if we write int then the function return integer value.
- The /*…*/ used for add additional comments in the program. This line will be ignored by the compiler it is known as comments in the program.
- clrscr() function clear the console. If you run program many times then the output of the previous program appears in the output of a current program. For clear the output of previous program the clrscr() function is used.
- printf() function is used for print and displays the message on the console.
- getch() function is waiting for a single character.
How To Compile and Execute C Program
- For compile c program press ctrl + f9 key or click on compile menu then click compile.
- After your program compiles press ctrl + f9 click on the run menu under Run to run the program.
- Now you will see the output of above program is “Hello World”.
- For exit, this screen press ESC button from your keyboard.