--Originally published at It's me
I did it! It was hard for me to find the solution but once I knew how to do it I did it “easily”. This assignment was similar to quiz 3, we needed to create functions and use them to print results. This time one function had to print the minimum value of three numbers; the other function had to sum the square of the same three numbers. The code of the first function was:
int minimumThree(int x, int y, int z){
int minimumThree;
if(x<=y && x<=z)
minimumThree=x;
else{
if (y<=x && y<=z)
minimumThree=y;
else{
minimumThree=z;
}
}
return minimumThree;
}
It was a little complicated and long because I had to evaluate each value for the computer to save the smallest. Ken told me to use <= in the if because if I had the same number in two or the three values, the function will work.
The other function was easy, all I needed to do was to calculate the square roots and do the sum. The code of this function was:
int sumSquares(int x, int y, int z) {
int sumSquares;
sumSquares=sqrt(x)+sqrt(y)+sqrt(z);
return sumSquares;
}
This is the complete code (there’s no image because the complete code doesn’t fit):
#include <iostream>
#include <cmath>
using namespace std;
int minimumThree(int x, int y, int z){
int minimumThree;
if(x<=y && x<=z)
minimumThree=x;
else{
if (y<=x && y<=z)
minimumThree=y;
else{
minimumThree=z;
}
}
return minimumThree;
}
int sumSquares(int x, int y, int
Continue reading "#Quiz04" →