FREE TUTORIALS ON C programming

Tuesday, December 24, 2013

First of all the most important thing in c programming is the ability of the language itself  to allow you to get closer to the system architecture unlike many other programming languages which hide the details from the programmer.

Before we begin to write programs in C we have to understand the basic nature of C program




#include<stdio.h>   //   -------------  1



int main()  // ----------------- 2



    {        // ---------------3



          printf("Hello World");   //---------------4

          
          getchar();        //----------------5





          return 0;       //--------------6





    } //----------------7


The above program might look a bit frightening at first but in order to understand any program we have to realize that no matter how much complex a program is we have divide it in one statement at a time and finally once we understand all the statements we will be able to get the complete picture.


  1. First line in our program is which is the include statement to be more precise in programming terms we call it PRE PROCESSOR DIRECTIVE now why do we need this statement or rather what we happen if we delete this statement are we going to run our program well i will answer that question and the answer is NO because this statement which happens to be the first statement in our program inform the the compiler abut certain keywords that we are going to use in our program.I know it might seem confusing because you have no idea what a compiler is or what are the keyboards but don't worry i will get to that once we finish dissecting this first c program. in short what you need to understand is that this first line does the work of a friend who knows address of some place where we want to go.. for example if we want to go to a particular place we need to have this friend with us then only we can reach our destination.


      2.The second line on our code is the main function which is the starting point of any c program and word before the main function is the return type of function well at present you won;t understand what does i means to return a value but don't worry when we go over the functions chapter i will clarify what a return value is but for the time being what it means is that every function has some purpose why it is created and return a value means returning the end result when we finish running the function.


     3. The third line which is the opening brace is the starting of a body of the c program



     4. The fourth line is the printf function from the standard c library which allows us to write on the screen



     5  The fifth line is the getchar function which allows us to enter a single character from the keyboard.



     6. The sixth line is the return value of the function , remember it is the same return value that we were talking about when we discussed about main function in the second line and again i will elaborate more on the return value when we talk about functions so if at present you are not able to get what is a return value don't panic.



    7. The seventh line is the end of the program which is indicated by the closing braces.

 

               

5:21 PM   Posted by Unknown with No comments

0 comments:

Post a Comment

Bookmark Us

Delicious Digg Facebook Favorites More Stumbleupon Twitter

Search