Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- double bignumber(double num1, double num2); //Declares the function 'bignumber'
- double smallnumber(double num1, double num2);//Declares the function 'smallnumber'
- void main()
- {
- double num1; //Holds the 1st number
- double num2;//Holds the 2nd number
- double num3;//Holds the 3rd number
- double bignum; //Holds the biggest number out of the 3 numbers
- double smallnum; //Holds the smallest number out of the 3 numbers
- cout << "Please enter three numbers: ";
- cin >> num1 >> num2 >> num3;
- bignum = bignumber(num1, num2); //Call to function 'bignumber'
- bignum = bignumber(bignum, num3); //Call to function 'bignumber'
- cout << "The biggest number amongst the 3 numbers you've entered is: " << bignum << endl;
- smallnum = smallnumber(num1, num2); //Call to function 'smallnumber'
- smallnum = smallnumber(smallnum, num3); //Call to function 'smallnumber'
- cout << "The smallest number amongst the 3 numbers you've entered is: " << smallnum << endl;
- }
- double bignumber(double num1, double num2) //This function will find the biggest of the two numbers
- {
- if ((num1 - num2)>=0) //Checks if num1-num2 is a non-negative number, therefor num1 is bigger or equal to num2
- {
- return(num1);
- }
- if ((num1 - num2)<0) //Checks if num1-num2 is a negative number, therefor num2 is bigger than num1
- {
- return(num2);
- }
- }
- double smallnumber(double num1, double num2) //This function will find the smallest of the two numbers
- {
- if ((num1 - num2) >= 0) //Checks if num1-num2 is a non-negative number, therefor num2 is smaller or equal to num1
- {
- return(num2);
- }
- if ((num1 - num2)<0) //Checks if num1-num2 is a negative number, therefor num1 is smaller than num2
- {
- return(num1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement