edited by
1,295 views

2 Answers

Best answer
5 votes
5 votes

Output is 3402  (3 and 402) but it is numerical hence answer should be 3402.

Initially p =0

in the first for loop

Itr 1 : arr[0] = 100 + 0 = 100  p++ => p = 1

p++ => p=2

Itr 2 : arr[2] = 300 + 2 = 302  p++ => p =3

p++ => p=4 (exit)

p-- => p=3.

next for loop q=8; inner p has scope only in its loop

Itr 1  : p = q right shift 1 => 8 (1000) >> 1 => 0100 (4)

arr[4] = 500+1 = 501

q-- = 7

Itr 2 : p = q right shift 1 => 7 (0111) >> 1 => 0011 (3)

arr[3] = 400 + 1 = 401

q-- = 6

Itr 3 : p = q right shift 1 => 6 (0110) >> 1 => 0011 (3)

arr[3] = 401 + 1 = 402

q-- 5 (exit)

Hence answer is p(outer) = 3, arr[p] = arr[3] =402

edited by
0 votes
0 votes
100 200 300 400 500 600 700 800 900

After First loop:

100 200 302 400 500 600 700 800 900

p=3

After second loop:

100 200 302 406 504 600 700 800 900

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

o/p:= 3,406

Related questions

0 votes
0 votes
2 answers
1
Debargha Mitra Roy asked Apr 10
100 views
What is the output of the below code?#include <stdio.h void main() { static int var = 5; printf("%d ", var ); if (var) main(); }a. 1 2 3 4 5b. 1c. 5 4 3 2 1d. Error
3 votes
3 votes
3 answers
2
Laxman Ghanchi asked May 19, 2023
1,158 views
#include<stdio.h void print(int n) { printf("Hello "); if(n++ == 0) return ; print(n); n++; } int main() { void print(); print(-4); }How many times printf execute?? And H...
0 votes
0 votes
1 answer
3
Laxman Ghanchi asked May 19, 2023
684 views
#include<stdio.h>void print(int n){ printf("Hello "); if(n++ == 0) return ; print(n); n++;}int main(){ void print(); print(-4);}