Write a preprocessor directive that makes it so SQUAREx retu

Write a \"preprocessor directive\" that makes it so \"SQUARE(x)\" returns the square of x.

Solution

#include <studio.h>

#define SQUARE(x) ((x)*(x))

main( )

{

int n,res;

printf (\" enter n value\ \");

scanf (%d,&n);

res = SQUARE (n);

printf (\"square of %d is = %d\ \",n,res);

}

output:

enter n value

4

square of 4 is = 16.

 Write a \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site