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
In python, what is the difference between a dictionary and a set? How are they similar?
yuradex [85]

Answer:

"A set is an unordered collection. A dictionary is an unordered collection of data that stores data in key-value pairs."

Explanation:

Set =>

Collection of non-repetitive elements.

Unordered

Unindexed

No way to change items.

Dictionary =>

Collection of key-value pairs.

Unordered

Indexed

Mutable

4 0
2 years ago
Consider the efficiency of locating the kth element in a singly-linked list. How does that compare to locating the kth element i
eimsori [14]

Answer:

Finding kth element is more efficient in a doubly-linked list when compared to a singly-linked list

Explanation:

Assuming that  both lists have firs_t and last_ pointers.

For a singly-linked list ; when locating a kth element, you have iterate through a number of k-1 elements which means that locating an element will be done only in one ( 1 ) direction

For a Doubly-linked list : To locate the Kth element can be done from two ( directions ) i.e. if the Kth element can found either by traversing the number of elements before it or after it . This makes finding the Kth element faster because the shortest route can be taken.

<em>Finding kth element is more efficient in a doubly-linked list when compared to a singly-linked list </em>

4 0
2 years ago
The strength of gravity on the Moon is 1.6
sergeinik [125]

Answer:

Mass = 80kg

Explanation:

Given

On Earth

Mass = 80kg

On the moon

g = 1.6N/kg

Required

The astronaut's mass on the moon

The mass of an object do not change base on location

So, if the mass of the astronaut is 80kg on earth, it will be 80 kg on the moon.

Hence:

Mass = 80kg

6 0
2 years ago
Before the 20th century how did most people experience computing​
frozen [14]

Answer:

   

Explanation:

3 0
2 years ago
If we use the square wave to transmit digital data (0s and 1s), what will be the data rate. Note data rate is the bits per secon
Nesterboy [21]
The maximum bit rate
6 0
2 years ago
Other questions:
  • What exactly is a byte? A byte is a term that is short for binary digit. 8 bytes hold about one letter, one number, or one speci
    10·1 answer
  • 1. Mobile devices have a _________ viewport that displays a web page content that fits within a mobile screen.
    11·1 answer
  • Ron wants to install an energy efficient and long lasting device for lighting in his new home. Which device should he use?
    11·2 answers
  • In modern computer memory, each location is normally composed of one byte.
    7·1 answer
  • A type of backlight technology most commonly used in modern laptop devices is called____________.
    9·1 answer
  • What is the purpose of the ISOWEEKNUM function?
    10·2 answers
  • Element primer a partir del qual es generarà l'energia central solar fotovoltaica
    9·1 answer
  • Suggest names for a coding club
    10·1 answer
  • Cách soạn thảo văn bản trên word
    7·1 answer
  • History of computer from difference engine <br>​
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!