Function

1: Write a program to add the two number using call by value;

   #include<conio.h>
   #include<iosteam.h>
 void sum (int, int);
 void main()
{
 int a,b;
cout<<"Enter the First Number";
cin>>a;
cout<<Enter the Second Number";
cin>>b;
sum( a,b);
getch();
}
void sum(int x, int y)
{
 int c= x+y;
cout<<"Sum of Number"<<c;
}
2: Write a program to subtract the two number using call by value;

   #include<conio.h>
   #include<iosteam.h>
 void sub (int, int);
 void main()
{
 int a,b;
cout<<"Enter the First Number";
cin>>a;
cout<<Enter the Second Number";
cin>>b;
sub( a,b);
getch();
}
void sub(int x, int y)
{
 int c= x-y;
cout<<"Subtract of Number"<<c;
}
3: Write a program to add the two number using call by value;

   #include<conio.h>
   #include<iosteam.h>
 void mul (int, int);
 void main()
{
 int a,b;
cout<<"Enter the First Number";
cin>>a;
cout<<Enter the Second Number";
cin>>b;
mul( a,b);
getch();
}
void mul(int x, int y)
{
 int c= x*y;
cout<<"Multiplication of Number"<<c;
}
4: Write a program to divide the two number using call by value;

   #include<conio.h>
   #include<iosteam.h>
 void div(int, int);
 void main()
{
 int a,b;
cout<<"Enter the First Number";
cin>>a;
cout<<Enter the Second Number";
cin>>b;
div( a,b);
getch();
}
void div(int x, int y)
{
 int c= x/y;
cout<<"Divide of Number"<<c;
}


No comments:

Post a Comment