Ad

Chapter - 8: The C Preprocessor

Write down macro definitions for the following:


Ad
C
Sections
4
Exercises

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)

Ad

© 2024 Garbage Valuegarbage value logo