--Originally published at Solving problems with programming
In quiz number 3 we have to do 2 funtcions. The first on has to return the smallest number of 3 numbers that the user gives. You are going to use conditionals and comparisons to get the samller number. But there is a problem, if there a two numbers that are equal and he the smallest you have to manege it. What I did is tell the user that are 2 numbers that are the smaller but are the same. I know there is another way to solve it better, I need to check the block of my classmates to find a better answer. The Second Function has to return the sum of the square of each number, this function is very easy.
#include
#include
using namespace std;
int minimumThree(int x, int y, int z){
if(x cout << “El número menor es= “;
return x;
} else if(y cout << “El número menor es= “;
return y;
} else if(z cout << “El número menor es= “;
return z;
} else if(z==y and z std::cout << “Hay dos números menores ” << endl;
}
}
int sumSquares(int x, int y, int z) {
int suma;
suma = pow(x,2)+ pow(y,2)+ pow(y,2);
cout <<“La suma de los números al cuadrado= “;
return suma;
}
int main(){
int num1,num2,num3;
cout<< “Escribe número 1″<<endl; cin >> num1;
cout<< “Escribe número 2″<<endl; cin >> num2;
cout<< “Escribe número 1″<<endl; cin >> num3;
cout <<minimumThree(num1,num2,num3)<<endl;
cout <<sumSquares(num1,num2,num3)<<endl;
}