You are on page 1of 21

Use code

DEVA10 to get
MAX Discount
Subscription

C Programming

By Mallesham Devasane (Mo - 9911691155)


#20 Rank

By Mallesham Devasane (Mo - 9911691155)


13th July to 31st July ( 11:00 AM to 12:30 PM)

By Mallesham Devasane (Mo - 9911691155)


Use code
to get
DEVA10 MAX Discount
Subscription

By Mallesham Devasane (Mo - 9911691155)


Use code
DEVA10 to get
MAX Discount
Subscription

By Mallesham Devasane (Mo - 9911691155)


Use code
DEVA10 to get
MAX Discount
Subscription

By Mallesham Devasane (Mo - 9911691155)


Use code
DEVA10 to get
MAX Discount
Subscription

By Mallesham Devasane (Mo - 9911691155)


Use code
DEVA10 to get
MAX Discount
Subscription

By Mallesham Devasane (Mo - 9911691155)


Use code
DEVA10 to get
MAX Discount
Subscription

Consider the following statements S1 and S2: 1


S1: Every iterative program can be done recursively
S2: Every recursive program can be done iteratively

Which of the following is correct about the statements S1 and


S2?

a) Only S1 is true
b) Only S2 is true
c) Both S1 and S2 are true
d) Both S1 and S2 are false

By Mallesham Devasane (Mo - 9911691155)


Use code
DEVA10 to get
MAX Discount
Subscription

Predict the output of the following program:


2
int f(int n){
if(n<=0) return 1;
else return (n+f(n-2));
}
void main(){
int n=8;
printf("%d",f(n));
}

a) 21
b) 31
c) 41
d) 51

By Mallesham Devasane (Mo - 9911691155)


Use code
DEVA10 to get
MAX Discount
Subscription

3
What is the value of ABC(10)-ABC(9)?:
int ABC(int a){
static int x=10;
if(a<0) return 0;
else
{ x=x-1;
return x + ABC(--a);
}
}
a) 1
b) 0
c) 10
d) 9

By Mallesham Devasane (Mo - 9911691155)


Use code
DEVA10 to get
MAX Discount
Subscription

4
What is the return value of the function call
ABC(10,10):
int ABC(int a, int b){
if(a==0) return b;
else return ABC(a-1,a+b);
}

a) 45
b) 55
c) 65
d) 75

By Mallesham Devasane (Mo - 9911691155)


Use code
DEVA10 to get
MAX Discount
Subscription

5
Predict the output of the following program:
int ABC(int x){
return x==0?0:x%10+ABC(x/10) ;
}
void main(void){
printf("%d", ABC(687)-ABC(1024));
}

a) 10
b) 12
c) 14
d) 16

By Mallesham Devasane (Mo - 9911691155)


Use code
DEVA10 to get
MAX Discount
Subscription

What is the relation between number of stars printed(assume “x”) 6


and n which is a non-negative integer?
void print(int n){
int i = 0;
if (n > 1) print(n-1);
while(i<n){ printf("*"); i++; }
}

a) x=n(n-1)/2
b) x=n(n+1)/2
c) x=n+1
d) x=n-1;
e) None of the above

By Mallesham Devasane (Mo - 9911691155)


Use code
DEVA10 to get
MAX Discount
Subscription

7
Predict the output of the following program:
int f(int x){
if (x == 0 || x ==1) return 1;
return f(x-1)+f(x-2);
}

void main(){
printf("%d", f(4));
}
a) 2
b) 4
c) 5
d) 6

By Mallesham Devasane (Mo - 9911691155)


Use code
DEVA10 to get
MAX Discount
Subscription

Predict the output of the following program for the call 8


fun(4)?
int fun(int k){
if (k<3) return k;
else return fun(k-1)*fun(k-2);
}

a) 2
b) 3
c) 4
d) 5

By Mallesham Devasane (Mo - 9911691155)


Use code
DEVA10 to get
MAX Discount
Subscription

Predict the output of the following program for the call 9


fun(4)?
int fun(int k){
if (k<3) return k;
else return fun(k-1)*fun(k-2)+fun(k-3);
}

a) 2
b) 3
c) 4
d) 5

By Mallesham Devasane (Mo - 9911691155)


Today

1) Test Yourself-2 (7 AM – 8 AM)


2) Nano CCTV Test 1 (1:30 PM – 2:30 PM)
3) DPP14 on C (Recursion) (3 PM - 4 PM)
4) GATE Questions on C (5:30 PM – 6: 30 PM)

By Mallesham Devasane (Mo - 9911691155)


Use code
DEVA10 to get
MAX Discount
Subscription
Use code
DEVA10 to get
MAX Discount
Subscription
Use code
DEVA10 to get
MAX Discount
Subscription

By Mallesham Devasane (Mo - 9911691155)

You might also like