# Quiz 04

--Originally published at prgrm.co

In this week’s quiz, the goal was to ask the user for three different numbers and then make two functions. The first function was to display the lowest of the three numbers, and the second one was to add the squares of the three numbers.

In order to accomplish this, I needed to include three different libraries.

• iostream
• cmath
• algorithm

Then the making of the functions, the first one which is to find the lowest number looks like this:

```int min3(int x, int y, int z){
return min(min(x, y), z);
}
```

Notice the way the “return min(min(x , y), z)” is written, this is due the fact that the “min” function works only for two integers, so by repeating the “min” function first it chooses between “x” & “y” and then between the result from this later & “z”.

The second function is to add the squares of the three numbers, this one is relatively easier as the only thing you need to do is multiply and add, like so:

```int sumofsquares(int x, int y, int z){
return ((x*x) + (y*y) + (z*z));
}
```

Here’s the full code:

```#include &lt;iostream&gt;
#include &lt;algorithm&gt;
#include &lt;cmath&gt;

using namespace std;

int min3(int x, int y, int z){
return min(min(x, y), z);
}

int sumofsquares(int x, int y, int z){
return ((x*x) + (y*y) + (z*z));
}

int main(){

int no1, no2, no3;

cout &lt;&lt; "This program will give you the lowest number and the sum of squares of the three numbers asked." &lt;&lt; endl;
cout &lt;&lt; "First: ";
cin &gt;&gt; no1;
cout &lt;&lt;"Second: ";
cin &gt;&gt; no2;
cout &lt;&lt; "Third: ";
cin &gt;&gt; no3;

cout &lt;&lt; "The smallest of the three numbers is " &lt;&lt; min3(no1, no2, no3) &lt;&lt; " ,the sum of the squares is " &lt;&lt; sumofsquares(no1, no2, no3) &lt;&lt;  Continue reading "Quiz 04" →```

# Quiz 04

--Originally published at prgrm.co

In this week’s quiz, the goal was to ask the user for three different numbers and then make two functions. The first function was to display the lowest of the three numbers, and the second one was to add the squares of the three numbers.

In order to accomplish this, I needed to include three different libraries.

• iostream
• cmath
• algorithm

Then the making of the functions, the first one which is to find the lowest number looks like this:

```int min3(int x, int y, int z){
return min(min(x, y), z);
}
```

Notice the way the “return min(min(x , y), z)” is written, this is due the fact that the “min” function works only for two integers, so by repeating the “min” function first it chooses between “x” & “y” and then between the result from this later & “z”.

The second function is to add the squares of the three numbers, this one is relatively easier as the only thing you need to do is multiply and add, like so:

```int sumofsquares(int x, int y, int z){
return ((x*x) + (y*y) + (z*z));
}
```

Here’s the full code:

```#include &lt;iostream&gt;
#include &lt;algorithm&gt;
#include &lt;cmath&gt;

using namespace std;

int min3(int x, int y, int z){
return min(min(x, y), z);
}

int sumofsquares(int x, int y, int z){
return ((x*x) + (y*y) + (z*z));
}

int main(){

int no1, no2, no3;

cout &lt;&lt; "This program will give you the lowest number and the sum of squares of the three numbers asked." &lt;&lt; endl;
cout &lt;&lt; "First: ";
cin &gt;&gt; no1;
cout &lt;&lt;"Second: ";
cin &gt;&gt; no2;
cout &lt;&lt; "Third: ";
cin &gt;&gt; no3;

cout &lt;&lt; "The smallest of the three numbers is " &lt;&lt; min3(no1, no2, no3) &lt;&lt; " ,the sum of the squares is " &lt;&lt; sumofsquares(no1, no2, no3) &lt;&lt;

# int sumSqueres (x,y,z) // Quiz Week 04

--Originally published at Alvaro_246

# Quiz04

En el Quiz de la semana #04 tuvimos un problema el cual consistía en ingresar 3 números (x,y,z) y el programa debe de imprimir el mas grande entre esos 3 números, pero esto haciéndolo como función “minimunThree (int a, int b, int c)” y en la segunda parte del quiz teníamos que elevar cada uno de estos 3 números al cuadrado y después sumar cada resultado, para esto coloque la siguiente formula “(x*x + y*y + z*z)=” dentro de la función sumSqueres(x,y,z)

#include <iostream>
using namespace std;

int minimunThree(int a, int b, int c) {
if(a>=b && a>=c){
return a;}
else if (b<=a && a<=b){
return b;}
else if (c<=a && c<=b){
return c;}
}

int sumSqueres(int x, int y, int z)
{
int R;
R= (x*x+y*y+z*z);
return R;
}

int main ()
{
float x,y,z;
cout << “Este programa encuentra el numero mas grande entre x,y,z” << endl;
cout << “Inserte el valor de x” << endl;
cin >> x;
cout << “Inserte el valor de Y” << endl;
cin >> y;
cout << “Inserte el valor de Z” << endl;
cin >> z;

cout<<“El numero mayor encontrado es: “<< minimunThree(x,y,z)<< endl;
cout<<“La suma de los cuadrados de los 3 numeros es: ” <<sumSqueres(x,y,z)<< endl;
return 0;
}
//Alvaro_246

# Quiz 04

--Originally published at Ken&#039;s Disciple 01

###### Picture by Stokpic

Hello everyone, on this week we had to do our Quiz 04, which was about minimum and squares. We had to ask a user to give us three numbers and we would give them the minimum of those three numbers and the sum of the squares of the numbers. We also had to do this program with the functions minimumThree and sumSquares.

Note: I’m actually learning how to give format to my program, soon I’ll be doing it easier to read and also I’ll be adding comments.

Everything in this program is the same, the only thing to highlight here is that we have to make sure that our functions return what we want them to return. In minimumThree I told the program to return the minimum of the numbers, which I did with the function min: this function returns the minimum of two numbers thats why I have  return min(x,min(y,z)); (returns the minimum of two numbers and then returns the minimum of that number plus the third one). In sumSquares its easy cause you ask the program exactly the operation you want it to do, simply as: return ((x*x)+(y*y)+(z*z));

Here are some pictures of the program, a blog of “Programming the city” that helped me, and my program as always on GitHub.

L.out

# X<Y and X*X (Minimum and Squares)

Today we had our 4th quiz, actually the semester is going very fast . Ken said:

I want you to (in class) create a program with two functions:

• int minimumThree(int x, int y, int z){ }  // returns the value that is smallest of x, y and z
• int sumSquares(int x, int y, int z) {}  // returns the value of the sum of squares of x, y, z

At the begging I was very lost cause I didn’t know how to make that, so I start looking what my other classmate did, and honestly it confused my a little cause everyone had something different, only one post really help me, but then Ken explained what is the function and how it’s supposed to work and then the knowledge finally comes to my.

So I make the function of minimumThree with a if/else if/else for give the smallest value. And the sumSquares I did by multiplying the variables by its self (like the title). The rest is pretty easy, you just write what you want the program “said”. This is my code:

Its very importan that in the function you establish what value does it supposed to return.

# Quiz#4

--Originally published at OlafGC / Class #TC1017

So today we did our fourth quiz, which consists on doing two functions, so there it goes. If you need help, there’s my twitter.

## Code:

#include <iostream>
using namespace std;

int minimunThree(int x, int y, int z)
{
if (x<=y && x<=z)
{
return x;
}
else if (y<=x && y<=z)
{
return y;
}
else if (z<=x && z<=y)
{
return z;
}
}

int sumSquares(int x, int y, int z)
{
return (x*x + y*y + z*z);
}

int main ()
{
int a, b, c;
cout<<“This program will tell you which number is the smallest out of three, and the sum of its square.”<<endl;
cout<<endl;
cin>>a;
cin>>b;
cin>>c;

int min= minimunThree(a,b,c);
int sum= sumSquares(a,b,c);

cout<<“The smallest number is: “<<min<<“.”<<endl;
cout<<“The sum of the square of those three numbers is: “<<sum<<“.”<<endl;
return 0;
} //Enrique Olaf García Cambero

# Quiz Week 4

--Originally published at how not to program

This program asks for three numbers and prints the minimum and the sum of their squares.

If you want to make improvements or modifications, here is the code for you to copy and paste it anywhere.

#include <iostream>
#include <cmath>
using namespace std;

int minimumThree (){

if (x<y||x<z) {
minimo= x;
}
else {
if (y<x || y<z ){
minimo =y ;
}
else {
minimo = z;
}
}

return minimo;
}

int sumSquares(){

}

int main (){
cout << “Type in any number” << endl;
cin >> x;
cout << “Type in any number” << endl;
cin >> y;
cout << “Type in any number” << endl;
cin >> z;

minimumThree();
sumSquares();

cout << “The minimum number is” << minimo <<endl;
return 0;
}

# Quiz 04

--Originally published at The Talking Chalk

#include <iostream>

using namespace std;

int minimumThree(int x, int y, int z)
{
if (x<=y && x<=z )
{
return x;
}
else if (y<=x && y<=z )
{
return y;
}
else if (z<=y && z<=x)
{
return z;
}

else
{
return x;
}
}

int sumSquares(int x, int y, int z)
{
return (x*x + y*y + z*z);
}
int main()
{
int a = 0;
int b = 0;
int c = 0;
cout<<“Please give me three integer numbers”<<endl;
cin>>a;
cin>>b;
cin>>c;

int minThree= minimumThree(a, b, c);
int Square = sumSquares(a, b, c);

cout<<“Smallest number: “<<minThree<<endl;
cout<<“Sum of squares: “<<Square<<endl;

return 0;
}

# Quiz #4

--Originally published at Programming 101

Today we had our fourth quiz and I found it quite hard. I thought about the problem and understood it but I had a bit of trouble writing it. In the end, a friend in class helped me and I got a better idea of what to do.

Functions were a bit of a headache for me but I’ll read more pages of the book and keep on working with my friends.

Here’s a screenshot of the program and three examples to show how it works.

Cheers!