fastread homefastrread library fastread menu

C : First C Program

Tutorial by:      Date: 2016-04-27 03:51:12

❰ Previous Next ❱

Before starting the abcd of C language, you need to learn how to write, compile and run the first c program.

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

 
  1. #include <stdio.h>  
  2. #include <conio.h>  
  3. void main(){  
  4. printf("Hello C Language");  
  5.   
  6. getch();  
  7. }  

#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.

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 to compile and run the c program

There are 2 ways to compile and run the c program, by menu and by shortcut.

By menu

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.

By shortcut

Or, press ctrl+f9 keys compile and run the program directly.

OUTPUT : Hello C Language

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

Now press Esc to return to the turbo c++ console.


clear screen by 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:

 
  1. #include <stdio.h>  
  2. #include <conio.h>  
  3. void main(){  
  4. clrscr();  
  5. printf("Hello C Language");  
  6.   
  7. getch();  
  8. }  

❰ Previous Next ❱


C

Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website