Quiz#4

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;
cout<<“Please insert the first number:”<<endl;
cin>>a;
cout<<“Please insert the second number:”<<endl;
cin>>b;
cout<<“Please insert the third number:”<<endl;
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

quiz04

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s