What is macro? Discuss the advantage & disadvantage.


 Definition of macro:-

Macro  are single identifies that are equal to complete statement as group of statement. Macro are user define constore program used in define statement through the pre- processor.

Types of Macro:-

1). simple macro

# define PI 3.14

2). Argument macro

# define identifiers ( Arg list)

3). Nested macro

# define max (x,y)

Advantage of Macro:-

1). Macro reduced the time delay assosiate with the function.

2). It increases execution time & speed.

3). It makes the program easy.

Disadvantage of Macro:-

1). Macro cannot use itself.

2). A Macro identified is not Association with an address.

 Example of Macro:-

/* Area of a circle*/

#include <studio.h>

#include<conio.h>

#define PI 3.14

void main ()

{

int r;

float A;

printf(" enter the radius");

scanf ("%d",& r);

A= PI *r*r ;

printf ("% f ", A);

getch ();

}


No comments:

Post a Comment

If you have any doubts, Please lets me know and Please Follow our Website