Originally Posted by

**bithub**
1. If a is less than b and a is less than c and a is less than d and a is less than e and a is less than f... that would make it the smallest number. In other words, you could solve this with a lot of if/else statements. If you have a lot of numbers that you're dealing with, then you should probably look into using a good sorting algorithm. A bubble sort is slow but easy to implement. On the other hand, a radix sort is fast but takes more work to implement. Since you are using c++, you can use a built in sorting algorithm. See

sort - C++ Reference
2. You cannot set the precision values. A float has a default amount of precision

**which is less than a double**. You can set the amount of numbers that get printed after a decimal point when you do a print though.

That will print a float value to 2 decimal places.

Thanks a lot, bithub.

Code:

#include <iostream>
int main()
{
float a, b, c, d, Mean;
std::cout << "Enter first number: ";
std::cin >> a;
std::cout << "Enter second number: ";
std::cin >> b;
std::cout << "Enter third number: ";
std::cin >> c;
std::cout << "Enter fourth number: ";
std::cin >> d;
std::cout << "The mean is: " << (a + b + c + d) / 4;
}

I'm a beginner and have only programmed one program so far (and that too, with the help of others!). I would be involved in comparing at least six numbers. I don't know how to implement IF...ELSE statements in C++. Could you guide me, or could you provide me an example by comparing two or more numbers?

What is "double"? How many 'default' number of digits would there be after the decimal point when using float? How and where to insert this code ?

Please guide me. It would be nice of you.

Best wishes

Jackson