Posted By:
9 Feb, 2014 2:02 am PST

First program in C

 

First Program

We all love Quick fixes, right?

C has come with a set of Libraries that are pre-defined, which help us perform many complex operations. We need to just import those libraries before writing the program. The library files are also called as Header Files, which have an “.h” extension.

After we install Turbo C, we can find the header files in “Include “directory.

Note: “//” are used as comment lines. That particular line which starts with “//” doesn’t come into picture when compiler compiles.

"headers"

The syntax of importing the libraries is:

#include<stdio.h>

#: This is a pre processor directive.

stdio.h: Standard Input Output Header file contains all the functions required for Input and Output operations.

So we import that header file using “include<stdio.h>”.

It includes the functions in “stdio.h” header file.

 

Program on the whole

#include<stdio.h>

int main()

{

printf(" Hi! Welcome to C tutorial ");

getchar();

return0;

}

 

#include<stdio.h>  

It is a pre processor directive that tells the compiler to load all the functions stored in STDIO header file.(STDIO-> Standard Input Output ).

 

Int

This is a Data type that tells the compiler that a integer type is returned as output.

 

main()

This is the main function of the C language . "()" are the parenthesis that tells us that it is  a function.

 

{

This is a flower bracket that indicates the start of a code.

 

printf(“”)

This is a function that is used to print something onto the console ( Screen ) .

 

;

Semi-colon is used to indicate the end of statement.

 

getchar()

After compiling the program , when we run it , the output is displayed in a separate black  console which will close automatically, once the output is displayed, in seconds.

 

return0

 tells the compiler that the program is successful.

 

 

Steps: 

1)       Open Turbo C

 "open"

2)       Click on File and press New.

"file"

"new"

 

3)       Type in the first program.

"first"

 

4)       Save the Program , click on File -> Save as -> enter required name.

"save"

"saved"

Compile the Program.

5)       "compiled"

         "compile"

      Run the program .

"run"

 

 

7)       Voila! Output is displayed.

"output"




Please login to reply to this problem.



Related Problems on Fixoncloud