#include<iostream>
#include<conio.h>
using namespace std;
int main()
{ int a,b,c,d;
cout<<"Enter 4 numbers to find maximum number"<<endl;
cin>>a>>b>>c>>d;
if(a>b)
{ if(a>c)
{cout<<a<<" is maximum"<<endl;}
else if(a>d)
{cout<<a<<" is maximum"<<endl;}
else
{cout<<d<<" is maximum"<<endl;}
}
else if(b>c)
{ if(b>d)
{cout<<b<<" is maximum"<<endl;}
else
{cout<<d<<" is maximum"<<endl;}
}
else if(c>d)
cout<<c<<" is maximum"<<endl;
else
cout<<d<<" is maximum"<<endl;
getch();
}
i"ll try to upload all the c++ programs which i have done::::: if there is mistake tell me in comments....
Showing posts with label if. Show all posts
Showing posts with label if. Show all posts
Friday, 11 December 2015
write a program which give following menu MANU OF PROGRAMpress 1: Add 2 two numbers"press 2: Add and multiply 3 numbers press 3: Enter two numbers and find maximum"press 4: Enter two numbers and find minimpress 5: Enter a value and find even or oddpress 6: Enter two values and swap them
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{ int number,a,b,c,sum,sum2,mul,swap;
cout<<" MANU OF PROGRAM"<<endl<<endl;
cout<<"press 1: Add 2 two numbers"<<endl<<endl;
cout<<"press 2: Add and multiply 3 numbers "<<endl<<endl;
cout<<"press 3: Enter two numbers and find maximum"<<endl<<endl;
cout<<"press 4: Enter two numbers and find minimum"<<endl<<endl;
cout<<"press 5: Enter a value and find even or odd"<<endl<<endl;
cout<<"press 6: Enter two values and swap them"<<endl<<endl;
cout<<"press a number 1-6"<<endl;
cin>>number;
if(number==1)
{ cout<<"Enter two numbers to add"<<endl;
cin>>a>>b;
sum=a+b;
cout<<"sum is = "<<sum<<endl;
}
else if(number==2)
{cout<<"Enter three numbers to add and multiply"<<endl;
cin>>a>>b>>c;
sum2=a+b+c;
mul=a*b*c;
cout<<"Sum is = "<<sum2<<endl;
cout<<"product is = "<<mul<<endl;
}
else if(number==3)
{cout<<"Enter two numbers to find maximum number"<<endl;
cin>>a>>b;
if (a>b)
cout<<a<<" is maximum"<<endl;
else if(b>a)
cout<<b<<" is maximum"<<endl;
}
else if(number==4)
{ cout<<"Enter two values to find minimum number "<<endl;
cin>>a>>b;
if(a<b)
cout<<a<<" is minimum"<<endl;
else if(b<a)
cout<<b<<" is minmum"<<endl;
}
else if(number==5)
{cout<<"Enter a number to find whether it is even or odd"<<endl;
cin>>a;
if(a%2==0)
cout<<a<<" is even"<<endl;
else
{
cout<<a<<" is odd"<<endl;}
}
else if(number==6)
{cout<<"Enter two values to swap"<<endl;
cin>>a>>b;
cout<<"you enter ("<<a<<","<<b<<")"<<endl;
swap=a;
a=b;
b=swap;
cout<<"values are swap = ("<<a<<","<<b<<")"<<endl;
}
else
cout<<"Enter values 1-6"<<endl;
getch();
}
#include<conio.h>
using namespace std;
int main()
{ int number,a,b,c,sum,sum2,mul,swap;
cout<<" MANU OF PROGRAM"<<endl<<endl;
cout<<"press 1: Add 2 two numbers"<<endl<<endl;
cout<<"press 2: Add and multiply 3 numbers "<<endl<<endl;
cout<<"press 3: Enter two numbers and find maximum"<<endl<<endl;
cout<<"press 4: Enter two numbers and find minimum"<<endl<<endl;
cout<<"press 5: Enter a value and find even or odd"<<endl<<endl;
cout<<"press 6: Enter two values and swap them"<<endl<<endl;
cout<<"press a number 1-6"<<endl;
cin>>number;
if(number==1)
{ cout<<"Enter two numbers to add"<<endl;
cin>>a>>b;
sum=a+b;
cout<<"sum is = "<<sum<<endl;
}
else if(number==2)
{cout<<"Enter three numbers to add and multiply"<<endl;
cin>>a>>b>>c;
sum2=a+b+c;
mul=a*b*c;
cout<<"Sum is = "<<sum2<<endl;
cout<<"product is = "<<mul<<endl;
}
else if(number==3)
{cout<<"Enter two numbers to find maximum number"<<endl;
cin>>a>>b;
if (a>b)
cout<<a<<" is maximum"<<endl;
else if(b>a)
cout<<b<<" is maximum"<<endl;
}
else if(number==4)
{ cout<<"Enter two values to find minimum number "<<endl;
cin>>a>>b;
if(a<b)
cout<<a<<" is minimum"<<endl;
else if(b<a)
cout<<b<<" is minmum"<<endl;
}
else if(number==5)
{cout<<"Enter a number to find whether it is even or odd"<<endl;
cin>>a;
if(a%2==0)
cout<<a<<" is even"<<endl;
else
{
cout<<a<<" is odd"<<endl;}
}
else if(number==6)
{cout<<"Enter two values to swap"<<endl;
cin>>a>>b;
cout<<"you enter ("<<a<<","<<b<<")"<<endl;
swap=a;
a=b;
b=swap;
cout<<"values are swap = ("<<a<<","<<b<<")"<<endl;
}
else
cout<<"Enter values 1-6"<<endl;
getch();
}
Subscribe to:
Posts (Atom)