Question

Create an array named data that can store 100 integers. Write a for loop that loops...

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.

Homework Answers

Answer #1

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!

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a function in c using #include <stdio.h> that takes a one-dimensional integer array and returns...
Write a function in c using #include <stdio.h> that takes a one-dimensional integer array and returns the index of the first occurance of the smallest value in the array. Your function must be able to process all the elements in the array. Create a function prototype and function definition (after the main function). Your main function should declare a 100 element integer array. Prompt the user for the number of integers to enter and then prompt the user for each...
Write recursive method to return true if a given array of integers, named numbers, with n...
Write recursive method to return true if a given array of integers, named numbers, with n occupied positions is sorted in ascending (increasing) order, or returns false otherwise. Array can be empty or not. //PRECONDITION: Varible n denotes the number of occupied positions in the array and must be non-negative. Employee class has method getSalary() that returns employee's salary. // An empty array and an array with single element in it, are sorted. Method isSortedRec must be recursive and returns...
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
Write a program which: Write a program which uses the following arrays: empID: An array of...
Write a program which: Write a program which uses the following arrays: empID: An array of 7 integers to hold employee identification numbers. The array should be initialized with the following values: 1, 2, 3, 4, 5, 6, 7. Hours: an array of seven integers to hold the number of hours worked by each employee. payRate: an array of seven doubles to hold each employee’s hourly pay rate. Wages: an array of seven doubles to hold each employee’s gross salary....
Create a new file named quiz_loops.py. b. Write your name and date in a comment. c....
Create a new file named quiz_loops.py. b. Write your name and date in a comment. c. Write a for loop which will display this set of values 2,4,6,8,10,12,14,16. d. Write a while which will display this set of values 16,13,10,7,4,1,-2. e. Write a for loop which will print ‘Loops are fun’ three times. f. Write a while loop that will prompt you for four numbers. Convert the number to an integer. Compute the power as power = power ** number....
• Use this array: string[] pets = {"dog", "cat", "parakeet", "guinea pig", "dire rabbit", "hamster", "ferret",...
• Use this array: string[] pets = {"dog", "cat", "parakeet", "guinea pig", "dire rabbit", "hamster", "ferret", "velociraptor"}; • Using a for loop go through the array o Change the value of each element by adding an s to the end o Print out the index and the animal at that index  e.g. when counter = 2 I should see  pet at index 2 is parakeets • Using the foreach loop, print out the items of the array •...
Create a program that allows the user to input a list of first names into one...
Create a program that allows the user to input a list of first names into one array and last names into a parallel array. Input should be terminated when the user enters a sentinel character. The output should be a list of emial addresses where the address is of the following form: [email protected] Declare FirstName[100] as String Declare LastName[100] as String Declare email as String Declare K as Integer Declare index as Integer Write "Enter first and last name." Write...
PLEASE COMMENT CODE AND TEST THAT IT WORKS: Write a assembly program to find the largest...
PLEASE COMMENT CODE AND TEST THAT IT WORKS: Write a assembly program to find the largest item in an array and store it in a AX. Hint: Use both Jump and loop instruction to write the program. logic: Assume that the first item of the array is the minimum and store it in AX Write a loop. Inside the loop, compare the each array item with the AX If the array item is less than the AX, update AX with...
Loop- Code Matlab -Solar Array Sizing A customer would like to install a solar panel array...
Loop- Code Matlab -Solar Array Sizing A customer would like to install a solar panel array for his small business. The daily peak power is estimated to be 50 kW and his budget is $10,000. Task 1: If the price for a single solar panel is $50, given the volume discount table below, how many solar panels can he afford? (Hint: see bottom of problem) Number of panels purchased Discount per panel 1 – 5 0% 6-29 10% 30 –...
Q) a) create a matrix named as X of evenly spaced values from 0 to 50,...
Q) a) create a matrix named as X of evenly spaced values from 0 to 50, with an increment of 10. b) a) create a matrix named as Y of evenly spaced values from 500 to 1000, with an increment of 3. c)a) create a matrix named as Z, the value of the 1st row is from 1 to 10, 2nd row from 2 to 20 with increment of 2, 3rd row 3 to 12. using subplot divide the window...