#include <iostream> // Required for input/output operations like
std::cout.
#include <cstdlib> // Contains functions for random number generation
(rand(), srand()).
#include <ctime> // Required for seeding the random number generator
using time(0).
// Function to generate a random number within a specified range.
int randBetween(int min, int max) {
return min + (rand() % (max - min + 1));
}
int main() {
// Seed the random number generator using the current time.
// This ensures a different sequence of random numbers each time the
program runs.
srand(time(0));
// Create an integer array to hold 10 values.
const int SIZE = 10;
int numbers[SIZE];
// Fill the array with 10 random numbers between -100 and 100.
for (int i = 0; i < SIZE; i++) {
numbers[i] = randBetween(-100, 100);
}
// Print the elements in the array.
std::cout << "Array Elements: ";
for (int i = 0; i < SIZE; i++) {
std::cout << numbers[i] << " ";
}
std::cout << std::endl;
return 0;
}