This set of C Multiple Choice Questions & Answers (MCQs) focuses on “External Variables – 2”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. What will be the output of the following C code?
#include <stdio.h>
double i;
int main()
{
printf("%g\n",i);
return 0;
}
a) 0
b) 0.000000
c) Garbage value
d) Depends on the compiler
View Answer
Explanation: None.
2. Which part of the program address space is p stored in the following C code?
#include <stdio.h>
int *p = NULL;
int main()
{
int i = 0;
p = &i;
return 0;
}
a) Code/text segment
b) Data segment
c) Bss segment
d) Stack
View Answer
Explanation: None.
3. Which part of the program address space is p stored in the following C code?
#include <stdio.h>
int *p;
int main()
{
int i = 0;
p = &i;
return 0;
}
a) Code/text segment
b) Data segment
c) Bss segment
d) Stack
View Answer
Explanation: None.
4. Can variable i be accessed by functions in another source file?
#include <stdio.h>
int i;
int main()
{
printf("%d\n", i);
}
a) Yes
b) No
c) Only if static keyword is used
d) Depends on the type of the variable
View Answer
Explanation: None.
5. Property of the external variable to be accessed by any source file is called by the C90 standard as __________
a) external linkage
b) external scope
c) global scope
d) global linkage
View Answer
Explanation: None.
6. What will be the output of the following C code?
#include <stdio.h>
int *i;
int main()
{
if (i == NULL)
printf("true\n");
return 0;
}
a) true
b) true only if NULL value is 0
c) Compile time error
d) Nothing
View Answer
Explanation: None.
7. What will be the output of the following C code?
#include <stdio.h>
int *i;
int main()
{
if (i == 0)
printf("true\n");
return 0;
}
a) true
b) true only if NULL value is 0
c) Compile time error
d) Nothing
View Answer
Explanation: None.
8. What will be the output of the following C code?
#include <stdio.h>
static int x = 5;
void main()
{
x = 9;
{
int x = 4;
}
printf("%d", x);
}
a) 9
b) 4
c) 5
d) 0
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – C Programming Language.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]
- Check Computer Science Books
- Check C Books
- Practice Computer Science MCQs
- Watch Advanced C Programming Videos
- Apply for C Internship