## taumang -10

``````please forward the function to calculate the smallest and largest without using (if,while else) statements
Input three different integers: 13 27 14

Sum 		Average		Product		Smallest		Largest
54		18			4914			13

#include<iostream>
using namespace std;
int main()
{
int x,y,z;
cin>>x>>y>>z;
cout<<"the sum is ="<<x+y+z<<endl;
cout<<" average is ="<<(x+y+z)/3<<endl;
cout<<" Product is ="<<x*y*z<<endl;
cout<<" smallest is="<<

return 0;
}``````
commented: I sent it, did you get it? -2

## jonsca 1,059

Make some attempt. What you have displayed shows only the most minimal effort.

## taumang -10

the problem is that i don't the function that will help me to get the smallest value and the largest value without using the while loop and if statement

## taumang -10

the problem is that i don't know the function that will help me to get the smallest value and the largest value without using the while loop and if statement

## jonsca 1,059

If you're not allowed to use if/else, are you allowed to use the ternary operator "? :" If so, check it out. If not, I can't think of a way offhand that doesn't use if.

## taumang -10

``````i want this program to give me average of 3,3 when i enter 2,3 and 5 and i want to include (smallest value and largest value to my screan dump)
#include<iostream>

using namespace std;

int main()
{

int sum;
int product;
float average;
int x,y,z;

cout<<" Enter Three Integers of your Choice "<<endl;
cout<<" *********************************** "<<endl;
cin>> x >> y >> z;

cout<<endl;

sum = x + y + z;

product = x * y * z;

average = static_cast<float>(sum)/3;

if( x > y && x > z )

cout<<" X = "<< x <<" is large\n\n\n"<<endl;

else

if( y > x && y > z )

cout<<" Y = "<< y <<" is Large \n\n\n"<<endl;

else

cout<<" Z = "<< z <<" is Large \n\n\n "<<endl;

if( x < y && x < z )

cout<<" X = "<< x <<" is Small \n\n\n "<<endl;

else

if( y < x && y < z )

cout<<" Y = "<< y <<" is Small \n\n\n "<<endl;

else

cout<<" Z = "<< z <<" is Small \n\n\n "<<endl;

cout<<endl;

cout<<" Sum "<<" \t "<<" Product "<<" \t "<<" Average "<<endl;
cout<<" *** "<<" \t "<<" ******* "<<" \t "<<" ******* "<<endl;
cout<< sum <<" \t\t "<< product <<" \t\t "<< average <<endl;

cout<<endl;

return 0;

}``````

## Chilton 22

Wasn't the assignment telling you not to use if, or while statements?

Also, it asks for you to do this in a function. Following the suggestion given, you can save many lines of code and create a similar function to return the largest value of the three.

## Tamlyn

Hmm perhaps you'll have to create 2 functions, and then your second function won't be using in if, or while statements.

``````float min2(float x, float y)
{
if (x < y)
return x;
else
return y;
}

float min3 (float x, float y, float z)
{
return min2(x, min2(y,z));
}``````

Does that help ?