UNIT3 MCQ C Language
UNIT3 MCQ C Language
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
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