C Programming Multiple Choice Question - Preprocessor And Macros

This section focuses on the "Preprocessor And Macros" of the C programming. These Multiple Choice Questions (mcq) should be practiced to improve the C programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. What is the output of this program?

        
#include <stdio.h>
#define int char
main()
{
  int i=50;
  printf ("sizeof (i) =%d", sizeof (i));
}

A. 2
B. 4
C. 8
D. 1

View Answer


2. What is the output of this program?

#include <stdio.h> 
#define x 3
int main()
{
  int i;
  i = x*x*x;
  printf("%d",i);
  return 0;
}

A. 27
B. x is not declared
C. No output
D. Garbage value

View Answer


3. What is the output of this program?

#include <stdio.h> 
#include  <stdlib.h>
#define square(x) x*x
int main()
{
  int i;
  i = 27/square(3);
  printf("%d",i);
  return 0;
}

A. 9
B. Compilation error
C. 3
D. 27

View Answer


4. What is the output of this program?

#include <stdio.h>
#define i 5
int main()
{
  #define i 10
  printf("%d",i);
  return 0;
}

A. Compilation error
B. 10
C. 5
D. Runtime error

View Answer


5. What is the output of this program?

#include <stdio.h>
#define clrscr() 17
int main()
{
  clrscr();
  printf("%d",clrscr());
  return 0;
}

A. Compilation error
B. Runtime error
C. 17
D. none of the above

View Answer


6. What is the output of this program?

		   
#include <stdio.h>
int main()
{
  printf("%d",30);
  return 0;
}

A. Runtime Error
B. Garbage value
C. Compilation error
D. 30

View Answer


7. What is the output of this program?

#include <stdio.h>
#define p 17;
int main()
{
  printf("%d",p);
  return 0;
}

A. Garbage value
B. Runtime error
C. 17
D. Compilation error

View Answer


8. Which statment is true about the given code ?

#include <stdio.h>
enum colors {lets,find,course};
int main()
{
  printf("%d %d %d",course,lets,find);
  return 0;
}

A. 3 1 2
B. 0 1 2
C. 2 0 1
D. 1 0 2

View Answer


9. What is the Error of this program?

#include <stdio.h>
#define CONDITION(x) 
printf("letsfindcourse");                         
int main()
{
  CONDITION(0);
  return 0;
}

A. letsfindcourse
B. Compilation error
C. Runtime error
D. None of the above

View Answer


10. How will you free the memory allocated by the following program?

#include <stdio.h>
#define CONDITION(x)
printf("letsfindcourse");                         
int main()
{
  CONDITION(0);
  return 0;
}

A. Runtime Error
B. letsfindcourse
C. Compilation error
D. None of the above

View Answer


11. What is a preprocessor directive

A. a message from compiler to the programmer
B. a message from programmer to the microprocessor
C. a message from programmer to the preprocessor
D. a message from compiler to the linker

View Answer


12. Which of the following are correctly formed #define statements?

A. #define INCH PER FEET 12
B. #define SQR(X) (X *X);
C. #define SQR(X) X*X
D. #define SQR(X) (X*X)

View Answer


13. A macro must always be written in capital letters.

A. TRUE
B. May Be
C. FALSE
D. Can't Say

View Answer


14. A macro should always be accommodated in a single line.

A. TRUE
B. May Be
C. FALSE
D. Can't Say

View Answer


15. After preprocessing when the program is sent for compilation the macros are removed from the expanded source code.

A. TRUE
B. FALSE
C. Can be true or false
D. Can't Say

View Answer


16. Macros with arguments are not allowed.

A. TRUE
B. May Be
C. FALSE
D. Can't Say

View Answer


17. Nested macros are allowed.

A. TRUE
B. May Be
C. FALSE
D. Can't Say

View Answer


18. Tn a macro call the control is passed to the macro.

A. TRUE
B. FALSE
C. May Be
D. Can't Say

View Answer


19. All macro substitutions in a program are done?

A. Before compilation of the program.
B. During execution
C. After compilation
D. None of the above

View Answer


20. In a program the statement: #include "filename" is replaced by the contents of the file "filename"?

A. Before compilation
B. During execution
C. After Compilation
D. None of the above

View Answer


21. Identify the trigraph sequence for .

A. ??/
B. ??=
C. ??
D. ??!

View Answer


22. Identify the trigraph sequence for^.

A. ??/
B. ??=
C. ??
D. ??!

View Answer


23. What is the output generated by the following code?
    #define square (a) (a*a)     printf("%d", square (4+5) ) ;

A. 81
B. 4
C. 29
D. None of the above.

View Answer


24. Undefined function calls in a C program.

A. by the preprocessor
B. by the linker
C. by the assembler
D. by the operating system are detected

View Answer


25. Identify the macro(s) defined in stdarg.h.

A. va_start
B. va_end
C. va_arg
D. all the above

View Answer


26. va_list is

A. a macro defined in stdarg.h
B. a predefined data type in stdarg.h
C. a macro defined in stdlib.h
D. a predefined data type stdlib.h.

View Answer


27. The following line in a program # represents

A. an invalid code
B. a null directive
C. a comment
D. a page number

View Answer


28. Identify the stringizing operator.

A. +
B. ::
C. #
D. ##

View Answer


29. The EOF character can be included in a file as part of its data

A. TRUE
B. May Be
C. FALSE
D. Can't Say

View Answer


30. The NULL character indicates an end of a string and a file.

A. TRUE
B. May Be
C. FALSE
D. Can't Say

View Answer




Also check :


Discussion


* You must be logged in to add comment.