Chapter - 8: The C Preprocessor

Write down macro definitions for the following:


C
Sections
4
Exercises

A

B

C

1

2

3

4

5

1. To find the arithmetic mean of two numbers. 
#define MEAN(x,y) ((x+y)/2.0)

 

2. To find the absolute value of a number. 
#define ABS(x) ((x<0)?(-1*x):x)

 

3. To convert an uppercase alphabet to lowercase. 
#define U2L(c) (c+32)

 

4. To obtain the bigger of two numbers. 
#define MAX(a,b) ((a>b)?a:b)


© 2020 Garbage Valuegarbage value logo