0% found this document useful (0 votes)
93 views

Assignment 7

A preprocessor directive is a message from the programmer to the preprocessor. The #define statements that are correctly formed preprocessor directives are #define INCH_PER_FEET 12 and #define SQR(X) (X*X). A header file is a file that contains macro definitions and standard library function declarations.

Uploaded by

hariharanbook
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views

Assignment 7

A preprocessor directive is a message from the programmer to the preprocessor. The #define statements that are correctly formed preprocessor directives are #define INCH_PER_FEET 12 and #define SQR(X) (X*X). A header file is a file that contains macro definitions and standard library function declarations.

Uploaded by

hariharanbook
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment - 7

Q1:

Answer the following

a) What is a preprocessor directive


1. A message from compiler to the programmer
2. A message from compiler to the linker
3. A message from programmer to the preprocessor
4. A message from programmer to the microprocessor
b)

Which of the following are correctly formed #define statements.


#define INCH PER FEET 12
#define SQR (X) (X*X)
#define SQR(X) X*X
#define SQR(X) (X*X);

Q2:

State True or false


1. A macro must always be written in capital letters
2. A macro should always be accommodated in a single line
3. After preprocessing when a program is sent for compilation the macros are removed from the expanded
source code

Q3: How many #include directives may be in the program


Q4: What is the difference between the two #include directives
#include conio.h
#include <conio.h>
Q5: A header file is :
a) A file that contains the standard library functions
b) A file that contains the definition and macros
c) A file that contains the user defined functions
d) A file that is present in current working directory
Q6: What will be the output of following program :
1) main( )
{
int i = 2;
#ifdef DEF
i *= i;
#else

printf(\n%d,i);
#endif
}
2) #define PRODUCT(x) (x*x)
main( )
{
int i = 3,j;
j = PRODUCT(i+1);
printf(\n%d,j);
}
3) #define PRODUCT(x) (x*x)
main()
{ int i=3,j,k;
j = PRODUCT(i++);
k = PRODUCT(++i);
printf(\n %d %d,j,k); }
Q7: Write down macro definitions for the following
1) To test whether a character entered is a small case

letter or not.

2) To test whether a character entered is a upper case

letter or not.

3) To test whether a character is an alphabet or not.


4) To obtain the bigger of two numbers.
Q8: Write macro definitions with arguments for calculation of area and perimeter of a triangle, a square and a circle.
Store these macro definition in a file called areaperi.h

You might also like