Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

1. What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         #define max 37;
  5.         printf("%d", max);
  6.     }

a) 37
b) Compile time error
c) Varies
d) Depends on compiler

View Answer

Answer: b [Reason:] None.

2. What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         #define max 37
  5.         printf("%d", max);
  6.     }

a) 37
b) Run time error
c) Varies
d) Depends on compiler

View Answer

Answer: a [Reason:] None.

3. What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         #define const int
  5.         const max = 32;
  6.         printf("%d", max);
  7.     }

a) Run time error
b) 32
c) int
d) const

View Answer

Answer: b [Reason:] None.

4. What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         #define max 45
  5.         max = 32;
  6.         printf("%d", max);
  7.     }

a) 32
b) 45
c) Compile time error
d) Varies

View Answer

Answer: c [Reason:] None.

5. What is the output of this C code?

  1.     #include <stdio.h>
  2.     # define max
  3.     void m()
  4.     {
  5.         printf("hi");
  6.     }
  7.     void main()
  8.     {
  9.         max;
  10.         m();
  11.     }

a) Run time error
b) hi hi
c) Nothing
d) hi

View Answer

Answer: d [Reason:] None.

6. What is the output of this C code?

  1.     #include <stdio.h>
  2.     #define A 1 + 2
  3.     #define B 3 + 4
  4.     int main()
  5.     {
  6.         int var = A * B;
  7.         printf("%dn", var);
  8.     }

a) 9
b) 11
c) 12
d) 21

View Answer

Answer: b [Reason:] None.

7. Which of the following Macro substitution are accepted in C?
a) #define A #define
    A VAR 20
b) #define A define
    #A VAR 20
c) #define #A #define
    #A VAR 20
d) None of the mentioned

View Answer

Answer: d [Reason:] None.

8. Comment on the following code?

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

a) No errors, it will show the output 20
b) Compile time error, the printf braces aren’t closed
c) Compile time error, there are no open braces in #define
d) None of the mentioned

View Answer

Answer: a [Reason:] None.

9. Which of the following properties of #define not true?
a) You can use a pointer to #define
b) #define can be made externally available
c) They obey scope rules
d) All of the mentioned

View Answer

Answer: d [Reason:] None.