PAPER 3 1.
(a) What are constants? Constants refer to fixed values, which do not change during the execution of a program. There are many types of constants in C as shown below: CONSTANT
NUMERIC
INTEGER
1.
2.
REAL
CHARACTER
SINGLE CHAR
STRINGS
(b) Name the different data types that C supports and explain them in detail. · Integer types—these are whole numbers without any decimal portion. They can be signed or unsigned. They are also classified as short and long integers depending on their value. · Floating point types—these are real numbers (with decimal portion) which are stored in 32 bits with 6 digits of precision. There are two types of such numbers in C. These are float and double. The data type double offers more precision when compared to float data type. · Character type—A single character is defined as a char data type. They are stored in one byte of internal storage. They can be signed or unsigned. Signed char can have values between 0 and 255 while unsigned have –128 to 127 ranges. · User defined data types—Apart from the above, the programmers can define their own data types using the typedef keyword. (a) Distinguish between getchar and scanf functions for reading strings. · getchar—this function allows us to read a character from the standard input (normally keyboard). Getchar is always used to read only one character at a time and never a string. The general form of getchar function is: