Functions & storage classes _ DPP 01 __ Parakram GATE 2024 Computer Science Weekend (English)
Functions & storage classes _ DPP 01 __ Parakram GATE 2024 Computer Science Weekend (English)
[NAT] print(-9);
1. Consider the following program: return 0;
#include<stdio.h> }
int f2(int a){ Which of the following is correct?
int b=0; (a) Compilation error
b=b+5; (b) “GATE Wallah” will be printed infinite number
return a*b; of times.
} (c) “GATE Wallah” will be printed 5 times.
int f1(int a){ (d) “GATE Wallah” will be printed 4 times.
int b;
b=f2(a); [MCQ]
3. Consider the following program.
return a*b;
#include<stdio.h>
}
void f(int n){
int main(){
switch(n<<1+n){
int i, a=5, b=4;
default: printf("Sresth");
for(i=0;i<2;i++){
case 4: printf("Parakram");
b-=f1(a)-f2(a);
case 3: printf("2024");
printf("%d\t", b);
break;
}
case 2: printf("2025");
return 0;
}
}
}
The sum of the printed values is ____________
int main(){
[MCQ] f(1);
2. Consider the following program: return 0;
#include<stdio.h> }
void print(int n){ The output is-
for(n++;n++;n++) (a) Parakram2024
printf("GATE Wallah"); (b) SresthParakram2024
} (c) Parakram
int main(){ (d) Sresth2025
void print();
void print();
2
Answer Key
1. (–292) 4. (b)
2. (d) 5. (5)
3. (a) 6. (c)
4
1. (–292) 2. (d)
For i=0: int main(){
f1(5): void print();//No compilation error
Line 1: int b; void print();//No compilation error
Line 2: b=f2(5);//b=25 print(-9); //print(-9) is called.
Line 3:return 5*25; //return 125 to main(). return 0;
f2(5): }
Line 1: int b=0; print(-9){//n=9
Line 2: b=b+5;//b=5
for(n++; n++ ;n++)
Line 3: return 5*5;//return 25 to f1.Go to Line 3 of
-9 -8 ->printf() is executed -7
f1(5)
f2(5): -6 ->printf() is executed -5
4. (b) 6. (c)
f(): r(4)=3. //Intialization
x = 10<5?printf(“%d”, printf(“GATE”)); r(n++)or r(4)=3->TRUE// Condition check
n is incremented to 5.
printf(“”)?printf(“2024”);
printf("%d\t",r(--n));// printf("%d\t",r(4))
printf(“%d”, printf(“Wallah Parakram”)); //3 is printed.
10<5 is FALSE. So, printf("") is evaluated. It prints r(--n) or r(3) is called.
nothing and hence returns 0. r(n++)or r(3)=2->TRUE// Condition check
0 means FALSE. So, printf("%d",printf("Wallah n is incremented to 4.
Parakram")) is evaluated.
printf("%d\t",r(--n));// printf("%d\t",r(3))
Output: Wallah Parakram15
//2 is printed.
For more questions, kindly visit the library section: Link for app: https://physicswallah.live/tabs/tabs/library-tab
For more questions, kindly visit the library section: Link for web: https://links.physicswallah.live/vyJw
Any issue with DPP, please report by clicking here- https://forms.gle/t2SzQVvQcs638c4r5