Thursday, 30 April 2015

Structure Of C Programs

By
 All the C Program are divided into many parts such as :
        Preprocessor Commands
        Functions
        Variables
        Statements and Expressions
        Comments

Preprocessor Commands :-

           Preprocessor Command is not a part of the compiler of c language but it is a diffrent step in the compilation time. All preprocessor commands starts with a (#) symbol.

Example :-

#define               Substitutes a preprocessor macro      
#include             Inserts a particular header from another file  
#undef                Undefines a preprocessor macro        
#ifdef                  Returns true if this macro is defined     
#ifndef                Returns true if this macro is not defined
#if                       Tests if a compile time condition is true
#else                    The alternative for #if
#elif                     #else an #if in one statement
#endif                  Ends preprocessor conditional
#error                  Prints error message on stderr
#pragma              Issues special commands to the compiler, using a standardized method

Main() Function :-

                we all know why main  function is used in c programs because when we run the program at that time program execution start with the main Function.

Syntax :-

int main()
{
// code write here
return 0;
}

Comments :-

         Comments are the statements that are ignored by the  compiler.

Syntax :-
                Multiline Comments :-
                /*    
                                  Comments statement that put here
                */
                Singleline Comments :-
                //     Comment statement put here for single line comments


Example of Hello World Program :-

#include<stdio.h>            //Preprocessor Commands
int main()                         //main()   program execution start to here
{
/* hello word program in c    */         //comments statements
printf(“Hello World…..\n”);    
return 0;                      

}

0 comments:

Post a Comment