--Originally published at blog de Horacio
What to do:
You implement these function in your own program in a file quiz4.cpp.
You should make a main routine that asks the user for three numbers and then calls your functions to which should *RETURN* the value and you print in the main program.
Publish your code on your own blog today (during class time is best) and use the tag #Quiz04 so it shows up nicely in our tag cloud.
#include <iostream>
#include <cmath>
using namespace std;
int sumSquares(int x, int y, int z) {
return pow (x,2)+pow(y,2)+pow(z,2);
}
int minimumThree(int x, int y, int z){
int num;
if (x<=y && y<=z) {
num=x;
}
if (y<=x && x<=z) {
num=y;
}
if (z<=y && y<=x) {
num=z;
}
return num;
}
int main()
{
int x,y,z;
std::cout << “give me the x variable” << ‘\n’;
std::cin >> x;
std::cout << “give me the y variable” << ‘\n’;
std::cin >> y;
std::cout << “give me the z variable” << ‘\n’;
std::cin >> z;
std::cout << “the sum of squares are: ” <<sumSquares(x,y,z)<< ‘\n’;
std::cout << “the minimun of the three numbers is: ” <<minimumThree(x,y,z)<< ‘\n’;
return 0;
}