For my homework assignment in C++, my goal is to write a program the inputs three integers and passes them to a function that returns the smallest number. This is only my 3rd week of C++, so I don't know much.
In addition, I'm only allowed to start off with #include<iostream>
and using namespace std
. I had been at this for hours,this just doesn't come easy to me. I've tried so many different things and I've only been getting errors...
This is the code I have so far that I actually understand:
#include <iostream>
using namespace std;
int fsmallestNumber(int);
int main() {
int numberOne;
int numberTwo;
int numberThree;
int smallestNumber;
cout << "Enter in 3 numbers and I will find the smallest of all three" << endl;
cin >> numberOne >> numberTwo >> numberThree;
cout << "The smallest of all three numbers is " << smallestNumber << endl;
}
int fsmallestNumber(int sn){
}
I'm confused on how to use the if/else statements to find the smallest number, and how to return the smallest number back into the function to print it out.