C MCQ set number 00703

1. What is the output of this C code?

  1.     #include <stdio.h>
  2.     double i;
  3.     int main()
  4.     {
  5.        printf("%gn",i);
  6.        return 0;
  7.     }

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?

  1.     #include <stdio.h>
  2.     int *p = NULL;
  3.     int main()
  4.     {
  5.         int i = 0;
  6.         p = &i;
  7.         return 0;
  8.     }

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?

  1.     #include <stdio.h>
  2.     int *p;
  3.     int main()
  4.     {
  5.         int i = 0;
  6.         p = &i;
  7.         return 0;
  8.     }

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?

  1.     #include <stdio.h>
  2.     int i;
  3.     int main()
  4.     {
  5.         printf("%dn", i);
  6.     }

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?

  1.     #include <stdio.h>
  2.     int *i;
  3.     int main()
  4.     {
  5.         if (i == NULL)
  6.             printf("truen");
  7.         return 0;
  8.     }

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?

  1.     #include <stdio.h>
  2.     int *i;
  3.     int main()
  4.     {
  5.         if (i == 0)
  6.             printf("truen");
  7.         return 0;
  8.     }

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?

  1.     #include <stdio.h>
  2.     static int x = 5;
  3.     void main()
  4.     {
  5.         x = 9;
  6.         {
  7.             int x = 4;
  8.         }
  9.         printf("%d", x);
  10.     }

a) 9
b) 4
c) 5
d) 0

Answer

Answer: a [Reason:] None.

ed010d383e1f191bdb025d5985cc03fc?s=120&d=mm&r=g

DistPub Team

Distance Publisher (DistPub.com) provide project writing help from year 2007 and provide writing and editing help to hundreds student every year.