1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sasho [114]
3 years ago
5

Write a program that creates an integer array with 40 elements in it. Use a for loop to assign values to each element of the arr

ay so that each element has a value that is triple its index. For example, the element with index 0 should have a value of 0, the element with index 1 should have a value of 3, the element with index 2 should have a value of 6, and so on.
Computers and Technology
1 answer:
iogann1982 [59]3 years ago
8 0

Answer:

public class Main

{

public static void main(String[] args) {

 int[] numbers = new int[40];

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

     numbers[i] = i * 3;

 }

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

     System.out.println(numbers[i]);

 }

}

}

Explanation:

*The code is in Java.

Initialize an integer array with size 40

Create a for loop that iterates 40 times. Inside the loop, set the number at index i as i*3

i = 0, numbers[0] = 0 * 3 = 0

i = 1, numbers[1] = 1 * 3 = 3

i = 2, numbers[2] = 2 * 3 = 6

.

.

i = 39, numbers[39] = 39 * 3 = 117

Create another for loop that iterates 40 times and prints the values in the numbers array

You might be interested in
A popular photo editing application provides customers with the option of accessing a web based version through a monthly subscr
Black_prince [1.1K]

Answer:

photoshop app that purchase with a lower price 3$ per month

6 0
2 years ago
All who are interested in forex trading and bitcoin mining follow me for account management to all who are busy with work so i c
masya89 [10]

I am very interested but too young just 10

8 0
3 years ago
Please check my answer! (Java)
Nat2105 [25]

9 is the correct answer. 4*2=8 loops are executed, moving the count from 1 to 9.

8 0
3 years ago
How do i protect my computer from electrical spikes
Setler [38]
I believe the answer is bloody purple poop that is the size of an extra large grilled cheese 
5 0
3 years ago
Read 2 more answers
An abstraction is a simplified representation of something that is more complex. Decimal numbers were a useful abstraction in th
Blababa [14]

What was the content of the lesson? It is hard to answer a question we need context on.

6 0
3 years ago
Other questions:
  • Distinguish the functional requirements an engineer would have to specify for a taxi dispatch system.
    8·1 answer
  • Write a function addOne that adds 1 to its integer referenceparameter. The function returns nothing.
    11·1 answer
  • What is the single most important component of a computer? Central Processing Unit DIP Motherboard Chipset
    8·1 answer
  • With microprocessors, The integration of a whole _____ onto a single chip or on a few chips greatly reduced the cost of processi
    14·1 answer
  • Who would use a CLI? (Command Line Interface)
    9·1 answer
  • Information is data converted into useful, meaningful context. What are data characteristics that change or vary over time?
    8·1 answer
  • Plymouth Colony was originally founded by a group of people called Pilgrims. Since Plymouth did not have an official charter fro
    15·1 answer
  • Algorithm to calculate the area of a square.​
    6·1 answer
  • Which tool uses images and other visual elements to provide artistic
    9·1 answer
  • If 200.123.4.6 is a classful internet protocol (ip) address, what class is it in?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!