Topics to be covered Introduction to C Introduction to C Characterstics of C Characterstics of C ...

Preview:

Citation preview

Topics to be coveredIntroduction to CCharacterstics of CCharactersetKeywordsConstantsTypes of constantsSymbolic Constants

Introduction to CC is a general purpose programming language. It was developed at AT & T’s Bell Laboratories of USA IN 1972. It was developed by Dennis Ritchie.

Back

Characteristics of C1. 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 SetA character consist of any letter or alphabet, digit or special symbol.Letters Uppercase A-Z

Lowercase a-zDigits All Decimal Digits 0-9Special 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:Auto Double int structBreak else long switchCase enum register typedefChar extern return unionConst float short unsignedContinue for signed voidDefault goto sizeof volatileDo if static while

Back

ConstantsConstant 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 constantsNumeric 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 -32768 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

0Examples: 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-3Forms of real constants areA) 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 Constants3) 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\n newline character\t tab\’ a single quote\” a double quote

Back

Symbolic ConstantsFormat for defining for symbolic constants isSyntax:#define symbolicname constantvalueExample: #define pi 3.143

This statement must not end with a semicolon and #define is known as preprocessor.

Back

Thanks

Recommended