In this article we are going to learn how to add two number entered by user in c programming language using function.
create function and initialize that function and call that function by passing parameter you want to add.
#include<stdio.h>
void main()
{
int a,b;
clrscr();
printf("\n Enter 2 Number:"); // user will enter two number one by one
scanf("%d %d",&a,&b); // number will store in variable a and b.
printf("\Addition=%d",add(a,b)); //calling function add
}
int add(int x,int y) // in function add passed two parameter x and y.
{
return(x+y); // adding two number
}
return will give output.
0 comments: