Q:

WHAT IS MACRO? WHY DO WE USE MACRO?

belongs to collection: C INTERVIEW QUESTIONS AND ANSWERS

0

WHAT IS MACRO? WHY DO WE USE MACRO?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Macro is a name which is given to a value or to a piece of code/block in a program. Instead of using the value, we can use macro which will replace the value in a program.

  • The reason for using macro is, consider below example.
  • You are using a person’s age as 50 in many places in your program. If you use direct value in all the places in your program, it is very difficult to change the age value in future if you want to change it to 60. If you use macro in your program, it is very simple to replace the value and we can change in only one place which will change the value in all places in your program.

Syntax: #define <MACRO_NAME> VALUE
Example:
Original declaration – #define AGE 50
Modified declaration – #define AGE 60

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C INTERVIEW QUESTIONS AND ANSWERS

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
WHAT IS DATA TYPE IN C?... >>
<< IS C LANGUAGE CASE SENSITIVE?...