Friday, August 13, 2010

Programming in C: Remember these points on constants.

A 'long' constant is written like 1234567697L or 567874338l. Big integer type constant is also taken as long. 'unsigned' constants written with a terminal u or U. 'unsigned' long type constants written with the terminal ul or UL. Floating point constants contain decimal point or an exponent (1e-1) or both. They are declared as 'double' type. The value of an integer can be specified as octal or hexadecimal. A leading zero on an integer constant means octal and a leading 0x or 0X means hexadecimal.

decimal : 31 octal : 031 hex : 0x1F

Character constants :

It is an integer. eg.'x'. A constant expression is an expression that involves only constants. They are used in any place where a constant occurs. A string constant or a string literal is a sequence of zero or more characters surrounded by double quotes.

In switch each case is labeled by integer valued constants or constant expressions. In the while and do loops 'continue' means that the test part is executed immediately. In for loop the control passes to the increment step. The continue statement applies only to loops not to 'switch'.

No comments:

Post a Comment