1. What is the output of this C code?
-
#include <stdio.h>
-
double i;
-
int main()
-
{
-
printf("%gn",i);
-
return 0;
-
}
a) 0
b) 0.000000
c) Garbage value
d) Depends on the compiler
Answer
Answer: a [Reason:] None.
2. Which part of the program address space is p stored in the code given below?
-
#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
Answer
Answer: b [Reason:] None.
3. Which part of the program address space is p stored in the code given below?
-
#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
Answer
Answer: c [Reason:] None.
4. Can variable i be accessed by functions in another source file?
-
#include <stdio.h>
-
int i;
-
int main()
-
{
-
printf("%dn", i);
-
}
a) 0
b) false
c) Only if static keyword is used
d) Depends on the type of the variable
Answer
Answer: a [Reason:] None.
5. Property of external variable to be accessed by any source file is called by C90 standard as
a) external linkage
b) external scope
c) global scope
d) global linkage
Answer
Answer: a [Reason:] None.
6. What is the output of this C code?
-
#include <stdio.h>
-
int *i;
-
int main()
-
{
-
if (i == NULL)
-
printf("truen");
-
return 0;
-
}
a) true
b) true only if NULL value is 0
c) Compile time error
d) Nothing
Answer
Answer: a [Reason:] None.
7. What is the output of this C code?
-
#include <stdio.h>
-
int *i;
-
int main()
-
{
-
if (i == 0)
-
printf("truen");
-
return 0;
-
}
a) true
b) true only if NULL value is 0
c) Compile time error
d) Nothing
Answer
Answer: b [Reason:] None.
8. What is the output of this 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
Answer
Answer: a [Reason:] None.