Presentation is loading. Please wait.

Presentation is loading. Please wait.

Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram. www.ustudy.in.

Similar presentations


Presentation on theme: "Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram. www.ustudy.in."— Presentation transcript:

1 Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram. www.ustudy.in

2 Introduction A constant is a quantity whose value does not change during programming execution. There are three types of constants they are Numeric constant Character constant String constant www.ustudy.in

3 Numeric constant A numeric constant is a constant made up of digits and some special characters. There are two types of numeric constants. They are Integer or fixed point constant Real or floating point constant www.ustudy.in

4 Integer constant Integer constant is a constant made up of digits without decimal point. This can have values from -32,708 to +32,627 Rules An integer constant is formed with digits 0 to 9. The constant can be preceded by + or – sign. No special characters are allowed anywhere in the constant. www.ustudy.in

5 Real Constant The numbers with decimal point are called real constant or floating point constant. A real constant is formed with the digits 0..9 and a decimal point. The number can be preceded by + or – The digits before and after the decimal point can be omitted. No white spaces or special characters are allowed. Floating point constants can be represented with f for floating and l for double precision floating point numbers. The real constants can be expressed in two forms a) Fraction form b) Exponential form www.ustudy.in

6 a)Fractional Form: The number is written with one decimal point Example: 2.1567.761 -34.7 are valid real number in fractional form. b) Exponential form: This is useful for representing very large or very small numbers in magnitude. The general form is Mantissa e or E exponent Example: The number 215.65 can be written in exponent notation as 2.1565e2 The number -0.0000375 can be written as -3.75e-5 www.ustudy.in

7 Character Constant There are two types of character constants. They are Direct Escape sequence www.ustudy.in

8 Single character constant: A single character constant consists of a single character enclosed within single quotes. The single character constants are stored in memory using their ASCII equivalent. So every character constant has an integer value corresponding to its ASCII value. For example the character 'A' has the equivalent integer ASCII value 65. Example: ‘$’ ‘e’ ‘9’ are character constants Here ‘9’ is not equal to numeric 9. www.ustudy.in

9 Escape Sequences The Escape Sequences are special characters for formatting. Character combinations consisting of a backslash (\) followed by a letter or by a combination of digits are called "escape sequences." These special printing characters are used to make the output readable when printing characters to the screen, file, or other device (such as printer). www.ustudy.in

10 Character for Bell (Alert) is.........................'\a'. Character for Backspace is.........................'\b'. Character for Horizontal Tab is...................'\t'. Character for Vertical Tab is.......................'\v'. Character for Newline (Line Feed) is..........'\n'. Character for Form Feed is.........................'\f'. Character for Carriage Return is................'\r'. Character for Quotation Mark is.................'\"'. Character for Apostrophe is.......................'\''. Character for Question Mark is...................'\?'. Character for Backslash is..........................'\\'. Character for Null is...................................'\0'. www.ustudy.in

11 String Constant A string constant is a sequence of characters enclosed within double quotation marks. This can be formed with digits, alphabets and special characters. Example: “C Program” “!Hello****” are valid string constants www.ustudy.in


Download ppt "Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram. www.ustudy.in."

Similar presentations


Ads by Google