Now let us understand some basic elements of c programming by the following program.
(NOTE:This program is used to print any sentence. Here the sentence is my name is akash parsania )
Here /* */ is called comment line whose between which any thing is written is not been displayed in output screen.It is simply use to know other user what particular instruction means or what this program does or to indicate date of making program,etc types of information.
Here #include is called "preprocessor directive" who tells the compiler to include code from the "header file" called stdio.h or conio.h .
To understand this let's compare the #include with library and stdio.h or conio.h
(header files) with library section.Now we know that in library there are many library sections say physics,mathematics etc but this section includes only particular set of books let's say physics section only includes physics related books it dosn't includes mathematics related book in same way stdio.h only include a particular set of functions out of which here we have used printf() and getch() were as clrscr() is included in conio.h.
Here void main() is used to tell the compiler that there is a function named main and function will not return any value hence void "data type" is used.
Here the "curly braces" ({ and }) indicates the beginning and ending of main function and function clrscr() tells the compiler to clear the screen that means to erase the previous output from the screen were as function printf() indicates the compiler to display the content in the output screen which is in between " ". Here it is my name is akash parsanaia and function getch() is used to order the compiler to hold the output screen until any button is not pressed.
So now do this program by yourself and then press RUN button or press ctrl+f9 if there will be no error in the program then u will get the output screen as shown below.
now press any key and u will again go back to your editor screen.
This was the simplest program in c language.
Now lets see some new programs.
PAGES: 1 // 2 // 3 //
No comments:
Post a Comment