Topics to be covered Introduction to C Introduction to C Characterstics of C Characterstics of C Characterset Characterset Keywords Keywords Constants Constants Types of constants Types of constants Symbolic Constants Symbolic Constants
Introduction to C C is a general purpose programming language. It was developed at AT & T’s Bell Laboratories of USA IN It was developed by Dennis Ritchie. Back
Characteristics of C 1. It is reliable, simple and easy to use. 2. There are only 32 Keywords in C. 3. It helps to develop structured programs. 4. C is highly portable. 5. User can add their own functions to the C library. 6. C is a format free language. 7. It is suitable for Graphics programming. 8. Pointer Implementation is available. Back
Character Set A character consist of any letter or alphabet, digit or special symbol. LettersUppercase A-Z Lowercase a-z Digits All Decimal Digits 0-9 Special Symbols + - * / # ? _ ‘ ;, : “ { } [ ] ( ) White Spaces, Blank Space, Tab Back
Keywords Keywords have their predefined meaning. They cannot be redefined by the programmers. They are also known as Reserved Keywords.
There are 32 Keywords in C: AutoDoubleintstruct Breakelselongswitch Case enumregistertypedef Charexternreturnunion Constfloatshortunsigned Continueforsignedvoid Default gotosizeofvolatile Doifstaticwhile Back
Constants Constant that remains unchanged during the execution of the program. Back Constants Numeric Constants Character Constatns Integer Constants Real Constants Single Character Constants String Constants
Types of constants Numeric Constants 1. Integer Constant: It is a sequence of digits without decimal point. Rules are: 1) It must have at least one digit. 2) It contains neither a decimal point nor an exponent. 3) Commas and blank spaces is not allowed. 4) Sign (+ or -) must precede the number. 5) Default sign is positive. 6) Allowed range is to 32767
There are three types of integer constants: 1) Decimal integers consists of a set of digits 0 to 9. Examples: 18,-11,+39,0 2) Octal integer constants consists of a set of digits 0 to 7 with a leading 0 Examples: 015,0375,0 3) Hexadecimal integer constant consist f a set of digits 0 to 9 or alphabets A(a) to F(f) with a leading 0x or 0X. Examples: Ox5,ox7d,0x79
2) Real Constants(Floating Point Constants): It is a number that contains either a decimal point or an exponent or both. Examples: 95.1,B0.012, 2.2e-5,11e+3, 2.3e-3 Forms of real constants are A) Fractional form real constants: Rules are: 1. A real constant must have atleast one digit. 2. It must contain a decimal point. 3. Commas and blank spaces is not allowed. 4. Sign (+ or -) must precede the number. 5. Default sign is positive. 6. It could be either positive or negative.
B) Exponential form real constants: Mantissa e exponent 1)The mantissa is either a real number expressed in decimal or an integer. 2) The exponent is always an integer number with an optional plus or minus sign. 3) The mantissa part may have a + or – sign. Default sign is +ve. 4) The mantissa part and the exponential part should be separated by a letter ‘e’. 5) Commas and blank spaces is not allowed. 6) Allowed range is -3.4e-38 to 3.4e38
Character Constants 3) Single Character Constant: A single character constant is a single character enclosed in single quotes. The character may be a letter, number or special character. Examples: ‘3’,’A’,’c’,”:” 4) String Constants: A string constant is a sequence of characters enclosed in double quotes. Examples: ‘B.SC.’,’1+3+4’,’V’,”HELLO”
Backslash character constants \nnewline character \ttab \’a single quote \” a double quote Back
Symbolic Constants Format for defining for symbolic constants is Syntax:#define symbolicname constantvalue Example:#define pi This statement must not end with a semicolon and #define is known as preprocessor. Back
Thanks