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