1. Point out the error in the function:
f(int a, int b)
{
int a;
a = 20;
return a;
}
A. Missing parenthesis in return statement
B. The function should be defined as int f(int a, int b)
C. Redeclaration of a
D. None of above
Answer : C
2. Which of the following statement are correct?
(i) The value stored in the CPU register can always be accessed faster than that stored in memory.
(ii) A register storage class variable will always be stored in a CPU register.
a) Only I is correct
b) Only II is correct
c) Both I & II are correct
d) Both I & II are incorrect
Answer : a)
3. Suppose a variable is declared with register storage class but no register is free then:
a) compilation error
b) data loss
c) it will occupy main memory
d) None of these
Answer : c)
C MCQ Set-13 Explanation
4. Predict the output of following code:
#include<stdio.h>
auto int var=200;
main()
{
printf(“The value of var is %d”,var);
}
a) 200
b) garbage value
c) compilation error
d) 0
Answer : c)
5. What will output of the code given bellow?
#include<stdio.h>
fib_term()
{
static int a=0,b=1;
int c;
c=a+b;a=b;b=c;
return c;
}
main()
{
int count=0,i;
for(i=0;i<5;i++)
printf(“%d “,fib_term());
}
a) 1 2 3 4 5
b) 1 2 3 5 8
c) 1 1 1 1 1
d) compilation error
Answer : b)
6. What will be output of the code given bellow?
#include<stdio.h>
int main()
{
register int a = 0;
printf(“%u”,&a);
}
a) garbage
b) hexadecimal memory location
c) 0
d) compilation error
Answer : d)
C MCQ Set-13 Explanation
7. What will be output of the code given bellow?
#include<stdio.h>
int main()
{
typedef int i;
i a = 0;
printf(“%d”, a);
return 0;
}
a) Compiler Error
b) Runtime Error
c) 0
d) 1
Answer : c)
8. What is the output of the following program?
#include<stdio.h>
int main()
{
extern int i;
i = 20;
printf(“%d”, sizeof(i));
return 0;
}
a) 20
b) 0
c) Undefined reference to i
d) 4
Answer : c)
9. What will be the output of the following code?
#include<stdio.h>
int main()
{
static int i=5;
if(–i)
{
main();
printf(“%d “,i);
}
}
a) 5 5 5 5
b) 0 0 0 0
c) 1 1 1 1
d) 4 4 4 4
Answer : b)
10. What will be the output of the following code?
#include<stdio.h>
int main()
{
extern int var;
printf(“The value of var is %d”, var);
return 0;
}
a) garbage
b) 0
c) No output
d) linking error
Answer : d)