Write a preprocessor command that calculates the square of an integer.


Difficulty level
This exercise is mostly suitable for students
#include <stdio.h>
#define SQUARE(x) (x)*(x)

int main()
{
     printf("Value = %d \n",SQUARE(2));
     printf("Value = %d \n",SQUARE(1+2*5-2%5));

     return 0;
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
N-ary tree