Tuesday, 12 April 2016

Write a program in c++ to find multiplication of two nos using function.

//wap in c++ to find multiplication of two nos using function.


Coding:-

#include<iostream.h>
#include<conio.h>

int mul(int num1,int num2);
int main()
{
clrscr();

int a,b;
cout<<"enter first no";
cin>>a;
cout<<"\n enter second no";
cin>>b;
int ret;
ret=mul(a,b);
cout<<"multiplication of two nos is:"<<ret;
getch();
return 0;
}

int mul(int num1,int num2)
{
int result;
result=num1*num2;
return result;
}
Output:-

Write a Program in c++ to find max no among two using function.

//wap in c++ to find max no among two using function.
 



Coding:-

#include<iostream.h>
#include<conio.h>

int max(int num1,int num2); //function Declaration
int main()
{
clrscr();



int a,b;
cout<<"enter first no:";
cin>>a;
cout<<"\n enter second no:";
cin>>b;
int ret;
ret=max(a,b);  //function call
cout<<"max value is:"<<ret;
getch();
return 0;
}
int max(int num1,int num2)
{
int result;
if(num1 > num2)
{
result=num1;
}
else
{
result = num2;
}
return result;
}



Output:-