125k views
3 votes
Declare and instantiate an array named scores of twenty-five elements of type int .

User Ilkar
by
5.9k points

1 Answer

3 votes

#include <iostream>

#include <ctime>

int main() {

int scores[25];

srand(time(NULL));

//Random fill

for(int i=0;i<25;i++) {

//Fill 0-10 randomly.

scores[i]=rand()%10;

}

//Print this array

for(auto& r:scores) {

std::cout << r << ", ";

}

return 0;

}

User Mmostajab
by
5.6k points