0% found this document useful (0 votes)
113 views13 pages

UNIT3 MCQ C Language

The document contains 11 multiple choice questions related to C programming concepts like functions, storage classes, recursion, scope rules etc. Each question has output options to choose from. The questions assess understanding of how C code with functions, parameters, recursion etc would execute and produce output.

Uploaded by

amit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views13 pages

UNIT3 MCQ C Language

The document contains 11 multiple choice questions related to C programming concepts like functions, storage classes, recursion, scope rules etc. Each question has output options to choose from. The questions assess understanding of how C code with functions, parameters, recursion etc would execute and produce output.

Uploaded by

amit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

MCQ

OF
Programming in C
Unit-3: User defined functions and Storage
classes
 Function prototypes, Function definition, Function Call
 passing arguments by value and passing arguments by reference(address),
 Math library functions,
 Recursive functions
 Scope rules (local and global scope),
 Storage classes in C
 auto,
 Extern,
 Register,
 Static
Q.1 What will be the output of the following code snippet?
#include <stdio.h>
a) 10 30
void solve() {
b) 30 10
int first = 10, second = 20;
c) 10 20
int third = first + second;
{ d) 20 10
int third = second - first; e) None of the above
printf("%d ", third);
}
printf("%d", third);
}
int main() {
solve();
return 0;
}
Q.2 What will be the output of the following code snippet?
#include <stdio.h>
a) 10
void solve() {
b) 5
int x = printf("Hello");
c) 1
printf(" %d", x);
} d) 0
int main() { e) None of the above
solve();
return 0;
}
Q.3 What will be the output of the following code snippet?
#include <stdio.h>
a) 35
void swap(int *a, int *b) {
int t = *a; b) 5 3
*a = *b;
c) 55
*b = t;
} d) 3 3

void solve() { e) None of the above


int a = 3, b = 5;
swap(&a, &b);
printf("%d %d", a, b);
}

int main() {
solve();
return 0;
}
Q.4 What will be the output of the following code snippet?
#include <stdio.h>
a) 023 23
void solve() {
printf("%d %d", (023), (23)); b) 23 23
}
c) 19 23
int main() { d) 23 19
solve();
return 0; e) None of the above
}
Q.5 What will be the output of the following code snippet?

a) Greater
b) Equal
c) Lesser
d) None of the above

#include <stdio.h>
void solve() {
int x = 1, y = 2;
printf(x > y ? "Greater" : x ==
y ? "Equal" : "Lesser");

}
int main() {
solve();
return 0;
}
Q.6 Which of the following is not a storage class specifier in C?

a) auto
b) extern
c) volatile
d) register
e) Static
f) None of the above
Q.7 What will be the output of the following code snippet?
#include <stdio.h>
a) 5
int get(int n) {
if(n <= 1) { b) 1
return n;
c) 0
}
return get(n - 1) + get(n - 2); d) 8
}
e) None of the above
void solve() {
int ans = get(6);
printf("%d", ans);
}

int main() {
solve();
return 0;
}
Q.8 What will be the output of the following code snippet?
#include <stdio.h>
a) 10
int main() {
int n = 10; b) 80
int f(int);
c) 30
printf("%d", f(n));
return 0; d) Compilation Error
}
e) None of the above

int f(int a) {
if(a > 1) {
return a + f(a-2);
}
}
Q.9 What will be the output of the following code snippet?
#include <stdio.h>
a) Hello is printed once
int main() {
printf("Hello"); b) No output
main();
c) Hello is printed infinitive times
return 0;
} d) Compilation Error
e) None of the above
Q.10 What will be the output of the following code snippet?
#include<stdio.h>
main() a) 24
{
int n; b) 4
n=f1(4);
c) 12
printf("%d",n);
} d) 10

f1(int x) e) None of the above


{
int b;
if(x==1)
return 1;
else
b=x*f1(x-1);
return b;
}
Q.11 How many times is ‘a’ printed when the following C code is executed?
#include<stdio.h>
main() a) 9
{
int a; b) 10
a=f1(10);
c) 0
printf("%d",a);
} d) Infinitive

f1(int b) e) None of the above


{
if(b==0)
return 0;
else
{
printf("a");
f1(b--);
}
}

You might also like