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
Phantasy [73]
2 years ago
12

What set of code correctly initializes all elements of the array ar to the value 0, given the declaration

Computers and Technology
1 answer:
Veronika [31]2 years ago
7 0

Answer:

The correct answer is:

C. ndx = 0;

while (ndx < 3) {

ar[ndx] = 0;

ndx++;

}

Explanation:

The declaration given is:

int ar[3];

This means the array consists of three locations and is named as ar.

We know that the indexes are used to address the locations of an array and the index starts from 0 and goes upto to 1 less than the size of the array which means the indexes of array of 3 elements will start from 0 and end at 2.

Now in the given options we are using ndx variable to run the while loop.

So the code to assign zero to all elements of array will be

ndx = 0;

while(ndx<3)

{

ar[ndx] = 0;

ndx++;

}

Hence, the correct answer is:

C. ndx = 0;

while (ndx < 3) {

ar[ndx] = 0;

ndx++;

}

You might be interested in
Does an android tablet have a hard drive
Kisachek [45]
No, it uses flash menory
3 0
3 years ago
State three reasons why users attach speakers to their computer​
____ [38]

Answer:

For listening sake

To listen to information from the computer

They receive audio input from the computer's sound card and produce audio output in the form of sound waves.

8 0
2 years ago
First, define an integer variable and assign it any value of your choice. Then you'll need to perform the following operations w
Tcecarenko [31]
Python code:

x=121
x += 9
x *= 2
x -= 4
x >>= 2
x -= 121
7 0
2 years ago
You have implemented a network where each device provides shared files with all other devices, what kind of network is it?
Reil [10]

It is a Peer-to-peer type of network when you have implemented a network where each device provides shared files with all other devices.

So the answer is Peer-to-peer.

8 0
2 years ago
Write a program using integers userNum and x as input, and output userNum divided by x four times. Ex: If the input is 2000 2, t
BaLLatris [955]

Answer:

import java.util.Scanner;

public class Division {

   public static void main(String[] args) {

    Scanner in = new Scanner(System.in);

       System.out.println("Enter an integer");

       int userNum = in.nextInt();

       System.out.println("Enter the divisor");

       int x = in.nextInt();

           int first = userNum/x;

           int second = first/x;

           int third = second/x;

           int fourth = third/x;

       System.out.println(first+" "+second+" "+third+" "+fourth);

   }

}

Explanation:

  • In Java programming langauge use the scanner class to receive the values from the user (userNum and x)
  • Carryout integer division of userNum/x to obtain the first number
  • Repeat the sam step to obtain the second, third and fourth number
  • Output the numbers to the user
5 0
3 years ago
Other questions:
  • What are the three main purposes of an operating system? Explain how the old mainframe computers were different from the compute
    12·1 answer
  • A user can set the security and privacy settings on what is displayed in the message bar from the ________ within the options me
    8·1 answer
  • Analyze the following code.
    12·1 answer
  • Write a program that will find the smallest, largest, and average values in a collection of N numbers. Get the value of N before
    13·1 answer
  • Random access memory is the portion of a computer's primary storage that does not lose its contents when one switches off the po
    6·2 answers
  • List the step in turning on a computer
    6·1 answer
  • I make a budget of my 1st Gamer PC its good?
    9·1 answer
  • 3. Windows that are viewed as Web pages have<br> sections. **
    9·2 answers
  • What software application is most appropriate to use to create multimedia presentations?
    6·2 answers
  • A search for reliable information is a search for what?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!