Hello,
I'm trying to work out these instructions -
1) The user is prompted to enter a positive integer, say n.
2) As long as n is between 10 and 30, the program will
a. Generate n number of random integers which will be no greater
than 99.
b. Print all these random integers 10 numbers per line and 6 spaces
per number.
c. Find and print the maximum and the minimum of these numbers.
Write two functions, FindMaximum and FindMinum. Each function
will return an integer and accept the following two parameters:
integer array and the size of the array.
d. Ask for another n.
For which I have:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#include "stdafx.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <iomanip>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int n;
int srand (time (NULL));
int i;
int x;
int c = 0;
cout << "Please enter a positive integer between 10 and 30 --> ";
cin >> n;
while (10 > n < 30)
{
for (c = 0, i = 0; i < n; i++)
{
x = rand()%100;
cout << setw (6) << x;
//checks for 10 numbers, and if there are 10, goes to the next line
c++;
if (c == 10)
{
cout << endl;
c = 0;
}
}
cout << endl;
cout << "\nPlease enter a positive integer between 10 and 30 --> ";
cin >> n;
}
return 0;
}
|
I can't figure out part c though. I understand arrays somewhat, but not what the teacher is asking me to do with the information. Specifically this -
'Each function will return an integer and accept the following two parameters:
integer array and the size of the array.'
I think the program works for 1) and 2)a.b.d. but not c
I would appreciate any help.