Professional Documents
Culture Documents
ALGORITHM:
(1) Start
(2) Define PI constant value 3.142
(3) Define macro function to pass a radius value as a argument
(4) Call the macro function
(5) Print the result
(6) Stop
PROGRAM:
#include<stdio.h>
#include<math.h>
#define PI 3.14
#define volume(r)((4/3.0)*PI*pow(r,3))
void main()
int r;
float v;
scanf("%d",&r);
v=volume(r);
}
Q(2) To print the elements of an array
ALGORITHM:
(1) Start
(2) Define macro function that receive array
(3) Repeat all the elements and print elements
(4) Call the macro function
(5) Stop
PROGRAM:
#include<stdio.h>
#define PRINTARRAY(a,l)\
int i=0;\
while(i<l)\
{\
printf("%5d",a[i]);\
i++;\
void main()
PRINTARRAY(a,10);
}
Q(3) To illustrate the use of these symbolic constants
ALGORITHM:
(1) Start
(2) Define + as ADD
(3) Define as SUB
(4) Define * as MULT
(5) Define / as DIV
(6) Perform addition using ADD and print the result
(7) Perform substraction using SUB and print the result
(8) Perform multiplication using MULT and print the result
(9) Perform division using DIV and print the result
(10) Stop
PROGRAM:
#include<stdio.h>
#include<math.h>
#define PLUS +
#define MINUS -
#define MULTI *
#define DIVI /
#define MOD %
void main()