A
A
Aniri142020-04-13 21:19:43
C++ / C#
Aniri14, 2020-04-13 21:19:43

Is the macro problem solved correctly?

Write a program containing macros with arguments that calculate the areas of various geometric shapes (for example, a square, a rectangle, a circle).

My decision:

#include <stdio.h>

#define SQ(a) (a) * (a)
#define REC(a,b) (a) * (b)
#define CIR(r) 3.14 * (r) * (r)

main () {
      printf("%d\n", SQ(67));
      printf("%d\n", REC(8,9));
      printf("%.2f\n", CIR(5));
}

Is it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-04-13
@0xD34F

No, not right.
For example, what do you think should be equal to 36 / SQ(6)? - Correctly think, unity.
What will your decision be? - 36.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question