Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- int max(int,int);
- float max(float,float,float);
- double max(double,double,double);
- int main()
- {
- int a,b,c;
- float x,y,z;
- double p,q,r;
- cout<<"enter a choice\n";
- cout<<"1.max of two integers\n";
- cout<<"2.max of three floats\n";
- cout<<"3.max of three doubles\n";
- cin>>a;
- switch(a)
- {
- case 1:
- cout<<"enter two inegers:\n";
- cin>>b>>c;
- cout<<"maximum of two integers is: "<<max(b,c)<<endl;
- break;
- case 2:
- cout<<"enter three floating point values:\n";
- cin>>x>>y>>z;
- cout<<"the maximum of three floating point values are: "<<max(x,y,z)<<endl;
- break;
- case 3:
- cout<<"enter three double values:\n";
- cin>>p>>q>>r;
- cout<<"the maximum of three floating point values are: "<<max(p,q,r)<<endl;
- break;
- default:
- cout<<"invalod operator\n";
- break;
- }
- return 0;
- }
- int max(int a,int b)
- {
- if (a>b)
- return a;
- else
- return b;
- }
- float max(float a,float b,float c)
- {
- if(a>b&&a>c)
- return a;
- else
- {
- if(b>c)
- return b;
- else
- return c;
- }
- }
- double max(double a,double b,double c)
- {
- if(a>b&&a>c)
- return a;
- else
- {
- if(b>c)
- return b;
- else
- return c;
- }
- }
- OUTPUT:
- enter a choice
- 1.max of two integers
- 2.max of three floats
- 3.max of three doubles
- 1
- enter two inegers:
- 24
- 75
- maximum of two integers is: 75
- Press any key to continue
- enter a choice
- 1.max of two integers
- 2.max of three floats
- 3.max of three doubles
- 2
- enter three floating point values:
- 42.4
- 62.4
- 75.4
- the maximum of three floating point values are: 75.4
- Press any key to continue
- enter a choice
- 1.max of two integers
- 2.max of three floats
- 3.max of three doubles
- 3
- enter three double values:
- 45.7594
- 45.8412
- 45.9985
- the maximum of three floating point values are: 45.9985
- Press any key to continue
Advertisement
Add Comment
Please, Sign In to add comment