Back to Home & C
//Program to find addition of two numbers using pass by value method
#include<stdio.h>
#include<conio.h>
int add(int,int);
void main()
{
clrscr();
int a,b,c;
printf("Enter two numbers\n");
scanf("%d%d",&a,&b);
c=add(a,b);
printf("addition=%d",c);
getch();
}
int add(int n,int m)
{
int s;
s=n+m;
return(s);
}
---------------------------------------------------------------
Output :
Enter two numbers
3
5
addition=8
=========================================================================
Back to Home & C
//Program to find addition of two numbers using pass by value method
#include<stdio.h>
#include<conio.h>
int add(int,int);
void main()
{
clrscr();
int a,b,c;
printf("Enter two numbers\n");
scanf("%d%d",&a,&b);
c=add(a,b);
printf("addition=%d",c);
getch();
}
int add(int n,int m)
{
int s;
s=n+m;
return(s);
}
---------------------------------------------------------------
Output :
Enter two numbers
3
5
addition=8
=========================================================================
Back to Home & C
2 comments:
why in the above program u did not define the variable name in first add function statement.
Defining variable names during function prototyping is not necessary. We can do it during the function definition.
Post a Comment