Sasi T. answered 07/30/19
I love to learn and spread knowledge!
Actually in your case there isn't a way to initialize all the values of the array to a single value without importing a library. Lets say you had an array of just 5 elements then you could just go ahead and type out the 5 numbers you would like to store. However, you say you have an array of 100 and it would to tedious to type 100 numbers. So you have 2 options here, as you said your first is to use a for loop and fill the array. The second option is to use a library called <algorithm>.
#include <algorithm>
using namespace std;
int main()
{
int sample[100];
fill(sample, sample + 100, -1);
return 0;
}
This would do the same thing. Great question.