Final exam, question #3 (or quiz #9)

Hi programigos! This is the video tutorial/code for solving the third question on our final exam: smallest_of_four. Enjoy and good luck!

#include <iostream>
using namespace std;

float smallest_of_four(int a, int b, int c, int d)
{
if(a<=b, a<=c, a<=d)
return a;
else if(b<a, b<=c, b<=d)
return b;
else if(c<a, c<b, c<=d)
return c;
else
{
return d;
}
}

int main()
{
int a, b, c, d;
cout<<“Insert the four numbers that you want to evaluate: “<<endl;
cin>>a;
cin>>b;
cin>>c,
cin>>d;
cout<<“The smallest number is “<<smallest_of_four(a, b, c, d)<<“.”<<endl;
return 0;
}

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