0
Pre processors.
Write macro definitions with arguments for calculation of area and perimeter of a triangle, a square and a circle. Store these macro definitions in a file called “areaperi.h”. Include this file in your program, and call the macro definitions for calculating area and perimeter for different squares, triangles and circles.
1 Odpowiedź
0
Hopefully this will help you get started:
.h file:
#ifndef AREAPERI_H
#define AREAPERI_H
#define AREACIRCLE(A) (3.14 * (A * A))
#endif
.c file
#include "areaperi.h"
#include <stdio.h>
int main(void){
float radius = 2.0;
printf("%5.2f is the area of a circle that has %3.2f radius", AREACIRCLE(radius), radius);
}