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
lions [1.4K]
2 years ago
12

What will the following code display? int numbers[4] = { 99, 87 }; cout << numbers[3] << endl; a. 87 b.0 d. 34. What

will the following code do? const int SIZE = 5; double x[SIZE]; for(int i = 2; i <= SIZE; i++) { x[i] = 0.0; } garbage This code will not compile a. Each element in the array is initialized to 0.0 b. Each element in the array, except the first, is initialized to 0.0 c. Each element in the array, except the first and the last, is initialized to 0.0 d. An error will occur when the code runs
Computers and Technology
1 answer:
pishuonlain [190]2 years ago
7 0

Answer:

1. The output is 0

2. Each element in the array is initialized to 0.0

Explanation:

Solving (a): The output of the code

We have:

<em>int numbers[4] = { 99, 87 }; </em>

<em>cout << numbers[3] << endl;</em>

<em />

The first line initializes the 0 and 1 index of the array to 99 and 87, respectively.

Other elements will be 0, by default.

So, the following code segment will output 0

<em>cout << numbers[3] << endl; </em>

<em />

Solving (b): What the given code will do?

The first and second line declares an array of 5 elements

However, the following iteration will only initialize the array with 0.0 starting from the second

<em>for(int i = 2; i <= SIZE; i++) { x[i] = 0.0; }</em>

<em />

Because, the counter is initialized to start from the second index.

You might be interested in
What name is given to the method used to copy a file onto a CD
Romashka-Z-Leto [24]

Answer: Burn or Write

Explanation:

Burn is a colloquial term meaning to write content to a CD , DVD , or other recordable disc. DVD and CD drives with recording capabilities (sometimes called DVD or CD burner s) etch data onto the disks with a laser .

4 0
3 years ago
Write a program that reads numbers from scanf (keyboard) and then sums them, stopping when 0 has been entered. Construct three v
almond37 [142]

Answer:

For loop Version:

#include <stdio.h>

int main()

{

   int number, sum = 0;

   printf("Enter a positive integer: ");

   scanf("%d", &number);

   

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

       if(number == 0)

           break;

       sum += number;

       

       printf("Enter a positive integer: ");

       scanf("%d", &number);

   }

   printf("Sum is: %d", sum);

   return 0;

}

- - - - -

While Loop Version:

#include <stdio.h>

int main()

{

   int number, sum = 0, i = 0;

   printf("Enter a positive integer: ");

   scanf("%d", &number);

   

   while (number != 0) {

       sum += number;

       

       printf("Enter a positive integer: ");

       scanf("%d", &number);

   }

   printf("Sum is: %d", sum);

   return 0;

}

Do-while Loop Version:

#include <stdio.h>

int main()

{

   int number, sum = 0, i = 0;

   

   do {

       printf("Enter a positive integer: ");

       scanf("%d", &number);

       

       sum += number;

       

   } while (number != 0);

   printf("Sum is: %d", sum);

   return 0;

}

Explanation:

- Initialize the variables

- Ask the user for the numbers until the user enters 0

-  Calculate and print the sum

4 0
2 years ago
Consider the following code:
ICE Princess25 [194]

Answer: 3

Explanation:

Because X = 18 and our condition given to the code if > and < which do not match with the input so it prints 3.

4 0
2 years ago
What is star topology
Alexxx [7]
Every node connects to a central network device. like a hub, switch, or computer.
4 0
2 years ago
Read 2 more answers
A(n) ____ , a type of idps that is similar to the nidps, reviews the log files generated by servers, network devices, and even o
kobusy [5.1K]
An LFM IDPS

Using an LFM which stands for log file monitor, the system is able to review log files generated by servers, network devices, and even other idpss. Its main purpose is to look for signatures and patterns which might indicate that an intrusion is in the pipeline or has already happened.
This intrusion detection is enhanced due to the fact that LFM is in a position to look at several log files from different systems.




8 0
2 years ago
Other questions:
  • Safety interlock module operates by monitoring the voltage from the
    7·1 answer
  • Powerpoint assumes that the first slide in a new presentation is the
    10·1 answer
  • I'm 11, except my profile says I'm 15.
    15·1 answer
  • Differences between electromechanical era and electronic era in point.<br>PLZ HELP​
    6·1 answer
  • An internal conflict is generally harder to write and still harder to convey in an interactive computer game
    7·1 answer
  • A palindrome is a string that reads the same both forward and backward. For example, the string madam is a palindrome. Write a p
    13·1 answer
  • Which programming element is used by a game program to track and display score information?
    10·2 answers
  • All banks follow the same guideline for determining if an applicant qualifies for a loan.
    13·1 answer
  • Write a q basic program to find the sum of all the even numbers from 1 to 50​
    14·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!