Sunday, 14 December 2014

C PROGRAM TO FIND SUM OF TWO NUMBERS (USING FUNCTION)

Write a program to find the sum of two numbers using function:

#include<stdio.h>
#include<conio.h>
int sum(int a, int b)
{
int c;
c=a+b;
return(c);
}
int main()
{
int x, y, z;
printf("Enter the two numbers");
scanf("%d %d",&x,&y);
z=sum(x,y);
printf("Sum of %d + %d is %d",x,y,z);
getch();
return(0);
}

Output:
Enter the two numbers
4 4

Sum of 4 + 4 is 8

No comments:

Post a Comment