What is the output of the following program?
#include
int main()
11
int arr [5] = {1, 2, 3, 4, 5);
arr [1] = 0;
arr [3] = 0;
for int i = 0; . < 5; -+1)
printf ("d", ar 21);
return 0;
return 0;

Respuesta :

The question is poorly formatted:

#include <stdio.h>

int main() {

int arr [5] = {1, 2, 3, 4, 5};

arr [1] = 0;

arr [3] = 0;

for (int i = 0;i < 5; i+=1)

printf("%d", arr[i]);

return 0;

}

Answer:

The output is 10305

Explanation:

I'll start my explanation from the third line

This line declares and initializes integer array arr of 5 integer values

int arr [5] = {1, 2, 3, 4, 5};

This line sets the value of arr[1] to 0

arr [1] = 0;

At this point, the content of the array becomes arr [5] = {1, 0, 3, 4, 5};

This line sets the value of arr[3] to 0

arr [3] = 0;

At this point, the content of the array becomes arr [5] = {1, 0, 3, 0, 5};

The next two lines is an iteration;

The first line of the iteration iterates the value of i order from 0 to 4

for (int i = 0;i < 5; i+=1)

This line prints all elements of array arr from arr[0] to arr[4]

printf("%d", arr[i]);

So, the output will be 10305