Here we will write a Program to add two numbers using Function. In this case Function is of type "Takes Nothing Returns Something" Which means the function doesn't take any argument from the main function but returns a value.
#include<stdio.h>
int add(void); // Function Declaration
int main()
{
int sum;
sum=add() ; // Function Calling
printf("Sum= %d\n,sum);
return 0;
}
int add() //Function Definition
{
int a,b,c;
printf("Give the two nos. : \n");
scanf("%d%d",&a,&b);
c=a+b;
return c;
}
No comments:
Post a Comment