Create an array named data that can store 100 integers. Write a for loop that loops 100 times. Inside the loop store the variable you are using to increment the loop into the current element of the array data. So the array data should have a 0 at index 0, a 1 at index 1, a 2 at index 2, ..., a 99 at index 99.
Explanation:
Here is the code which creates an array named data, which can store 100 integers.
Now, for loop runs from i =0 to i=99, and keep storing i at ith index.
For java, the declaration would be:
int data[] = new int[100];
Code:
#include <iostream>
using namespace std;
int main()
{
int data[100];
for (int i = 0; i < 100; i++) {
data[i] = i;
}
return 0;
}
PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!
Get Answers For Free
Most questions answered within 1 hours.