More output functions; still just not understanding...

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
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;
// PrintThis.cpp

/* Sample Output
     5106
     1607
    19752
    11226
     3830
    23674
    29202
    20171
    22608
    13347

*/

int main()
{
   // prototype
   void printThis(int);

   const int NUMBERS = 10;

   int randomValue;


   srand(time(NULL));
   for (int index = 0; index < NUMBERS; index++)
   {
      // call function to create a random number
      randomValue = rand();

      // call your function to display random number
      printThis(randomValue);
   }

   cin.get();
   return 0;
}

//-------------------------------------------------------------------
// Output Function - code the printThs() function below
// parameters: randomValue :  int
// returns: none
//-------------------------------------------------------------------

Same issues as I mentioned in your other thread..
So would this one be like so...?

1
2
3
4
void printThis (int randomValue)
{
 cout << randomValue;
}
yes, that would be correct except you need to output a new line.
1
2
3
'\n'
//or
std::endl;
Last edited on
awesome...! I have more I'll post with my attempts..
Topic archived. No new replies allowed.