Tuesday, December 12, 2017

How works c function in programing langauge

Works c function

The C function has three distinct aspects, namely:

 1).
         The prototype, which you can also term function declaration. What this one does is keep the compiler informed on the issues of function name; the function parameters; as well as the return value of the data type.
        The syntax for the function declaration is: return_type function_name ( argument list ); 


2).
         The function call This is the caller of the real function.
      Its syntax is: function_name ( arguments list );

 3).
         The function definition This is where you find the entire set of statements requiring execution. 
         The syntax for the function definition is: return_type function_name ( arguments list ) { body of function; }

For example : -

Function are working 
4)

Firstly Operating System will call our main function.

5).

When control comes inside main function , execution of main starts (i.e execution of C program starts)

6).

Consider Line 4 :

num = square(4);

We have called a function square(4).

For example:-
    
     #include<stdio.h> 
    #include<conio.h>

 int sum(int,int) ;

void main() 


    
int w , x , y , z ;

 printf ( " \n Enter the three numbers : " ); 

scanf( "%d%d" ,& x ,& y ,& z ) ;

w = sum ( x , y , z) ;

printf ( " \n Addition of three number is : %d" , w ) ;

getch() ; 

}
int sum (int num1,int num2,int num3) 



int num4 ;

 num4 = num1 + num2 + num3 ;

return ( num4 ) ;

 }

7).

We have passed “4” as parameter to function.

Note : 

          Calling a function halts execution of the current function , it will execute called function , after execution control returned back to the calling function.




0 comments:

Please comment and follow this site blog inbox