Tuesday 25 September 2012

Function001

Write a function to input two numbers and print there sum.

#include <stdio.h>
#include <conio.h>
int          sum ( int, int );                        /* Function prototype declaration */
void main ( )
{    
        int    i, j, k;
        clrscr ( );
                
        printf("\n\n\t\t Enter first number....:"); scanf("%d", &i);
        printf("\n\n\t\t Enter second number...:"); scanf("%d", &j);
                      
        k = sum ( i, j );                          /* Function calling */
                                    
        printf("\n\n\t\t SUM = %d", k);
        getch ( );
}                             
             
int     sum ( int    x, int    y )               /* Function Definition */
{          
         int    z;
         z = x + y;
         return ( z );
}
Click here to contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...