C Programming _ Weekly Test 02 - Test Paper
C Programming _ Weekly Test 02 - Test Paper
for(;j<i;j*=8) (b) 1
{ (c) Infinite Loop
i+=1; (d) 2 4
printf("GATE Wallah 2023\n");
} [MCQ]
return 0;
6. #include <stdio.h>
}
int main()
The number of times ‘GATE Wallah 2023’ is printed {
is-
int a = 10 > 9 ? 0 ? 3 : -2 : 5;
(a) 3 (b) 2
(c) 4 (d) 5 if(a = a + 1)
printf("GATE 2023");
[MCQ]
else
5. #include<stdio.h>
printf("GATE WALLAH");
void main()
{ return 0;
int x=5;
}
if(printf("%d",x>>1)-3)
for(;x--;x--) break; The output is-
else; (a) GATE 2023
printf("\t%d", x); (b) GATE WALLAH
}
(c) Compiler error
The output is- (d) Garbage value
(a) Compiler Error
Q.7 to 13 Carry TWO Marks Each
[NAT] break;
7. Consider the following program: }
#include<stdio.h> j++;
int main() printf("%d\n",p);
{ }
int p,j=0; return 0;
for(p=2;p<=100 && j<3;p*=2){ }
switch(p+j){ The sum of the values printed is ________________
case 1: p+=3;
break;
[NAT]
case 2: p+=5; 8. #include <stdio.h>
case 3: p+=7; {
n 1
(a) 3n (b)
2
(c) lon3n (d) log3log3n
5
Answer Key
1. (d) 9. (c)
2. (b) 10. (d)
3. (a) 11. (31)
4. (c) 12. (a, b, c)
5. (d) 13. (a, b, c, d)
6. (a)
7. (81)
8. (12)
6
a = 80 Output: 2 4
p = 22 * 2 = 44 4 < = 2 → True
switch (44 + 2) – Post – decrement / increment operator assigns and
default: ✓ p += 8 → 52 is printed then decrements / increments.
52 * 2 = 104 a 5 b 1
104 < = 100 → false Output is : 5 1
sum of printed values = 7 + 22 + 52 = 81
11. (31)
8. (12) a 0 1 2 3 4 5 6
Sol. printf() prints and returns the number of characters
it printed. “best hai GATE Wallah” is printed. b 1 3 4 6 7 9 10 12 13 15 16 18 19 21 22 24 25
9. (c) b = b + 2;
Sol. i=j++<--k?++j:k--; //4<2-> TRUE, so, k—is 1+2→3 10 + 2 → 12 19 + 2 = 21
evaluated. i takes the value 2. 4+2→6 13 + 2 → 15 22 + 2 = 24
i = 2, k=1, j=5; 7+2→9 16 + 2 → 18
for (++i; ++i; ++i) }
while (b ++ < = 10);
{ 3 < = 10 → true
6 < = 10 → true
9 < = 10 → true
34 5
12 < = 10 → False
67 15 < = 10 → False
18 < = 10 → False
89
21 < = 10 → False
10 24 < = 10 → False
printf (“%d\t”, i); // 4 6 8 10 Final value –
Sum = a + b = 6 + 25 = 31
10 > 8 break
} 12. (a, b, c)
For more questions, kindly visit the library section: Link for web: https://smart.link/sdfez8ejd80if