My boss asked me to write
a program that accepts an array of integers and prints the minimum of the numbers
What does he mean by that ??
My boss asked me to write
a program that accepts an array of integers and prints the minimum of the numbers
What does he mean by that ??
You'd probably have to ask him or her to be sure.
Normally that would mean reading integers from a file or standard input and then outputting to a file or standard output the smallest number you read in.
Can you help me with the Code please ?
:-) Invisible ?
We generally help with existing code. You try and if you have a specific question you ask. It's hard to help with the code when there is no code to help with.
When you have code to show, make sure to post it in [code][/code] tags.
Code:#include <iostream> using namespace std; char DoMenu(); void find_largest(); void find_smallest(); int main() { char choice; do { choice = DoMenu(); switch (choice) { case 'a': // fall through case 'A': find_largest(); break; case 'b': case 'B': find_smallest(); break; } } while ((choice != 'C') && (choice != 'c')); return 0; } char DoMenu() { char MenuChoice; cout << "A - Find the largest # with a known quantity of numbers\n"; cout << "B - Find the smallest # with an unknown quantity of numbers\n"; cout << "C - Quit\n"; cout << "Please enter your choice: "; cin >> MenuChoice; return MenuChoice; } void find_largest() { int largest = 0; int numbers=0, input, i=0; cout << endl; cout << "How many numbers to enter: "; cin >> numbers; for (i=0; i<numbers; i++) { cout << "Enter number " << i+1 << ": "; cin >> input; if (input > largest) largest = input; } cout << endl; cout << "Largest: " << largest << "\n\n"; } void find_smallest() { int smallest = 9999; int input=0, i=1; cout << endl; do { cout << "Enter number " << i << ": "; cin >> input; i++; if ((input < smallest) && (input != -99)) smallest = input; } while (input != -99); cout << endl; cout << "Smallest: " << smallest << "\n\n"; }
That's nice code that you apparently found on the internet: http://www.dreamincode.net/forums/showtopic20751.htm
But if you aren't going to do any work yourself it makes no sense for us to do it for you.
Now, as I have Code, I can study it and learn from it...
I encourage you to do so. I just wanted others to be aware, in case it wasn't obvious, that your posted code wasn't something you came up with and needed help with.
Your boss asked you to write this eh? Seems very simplistic for 'work stuff'.