include int main Give the output of the following program a

#include int main() { //Give the output of the following program, as well as the contents of the array arr when prompted int I; int arr[5]; char letter = a; int x = 10; printf(%c\ , letter); for(i = 11; i > 6; i--) { arr[i 7] = i + 3; } //current contents of arr: ___ ___ ___ ___ ___ for (i = 0; i

Solution

Output of the program is : a

Loop 1: current contents of arr is : 10 11 12 13 14

Loop 2: current content of arr is : 4 3 2 1 0

Explanation for Loop 1:

i runs from 11 to 7 and value arr is initialized,

when i =11

=> arr[11-7]=11+3

=> arr[4]=14

Similarly, arr[3]=13, arr[2]=12, arr[1]=11, arr[0]=10

Explanation for Loop 2:

i runs from 0 to 4 and value of arr is initialized as below:

when i =0

=> arr[arr[4-0]%5] = 0

=> arr[arr[4]%5] = 0. Since arr[4] = 14

=> arr[14%5] = 0 (14%5=4)

=> arr[4] = 0

Similarly, arr[3]=1, arr[2]=2, arr[1]=3, arr[0]=4

 #include int main() { //Give the output of the following program, as well as the contents of the array arr when prompted int I; int arr[5]; char letter = a; in

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site