I am trying to output 25 random values between 3 and 7 using a function. Every time I run my program I receive two values that are within those parameters but the rest are out of the range.
#include <iostream>
#include <iomanip>
using namespace std;
void showArray(int a[], int size);
void showArray(int a[], const int size)
{
int i;
for (i = 0; i < size; i++)
{
cout << a[i] << ", ";
}
}
int main()
{
//int iseed = time(NULL);
//srand(iseed);
srand(time(NULL));
int randomNumb = rand() % 3 + 4;
int array[] = {randomNumb};
showArray(array, 25);
this is my Output : 4, 4, -300313232, 32766, 540229437, 32767, 0, 0, 1, 0, -300312808, 32766, 0, 0, -300312761, 32766, -300312743, 32766, -300312701, 32766, -300312679, 32766, -300312658, 32766, -300312287,
Aucun commentaire:
Enregistrer un commentaire