Presentation is loading. Please wait.

Presentation is loading. Please wait.

C++ Basics.

Similar presentations


Presentation on theme: "C++ Basics."— Presentation transcript:

1 C++ Basics

2 C++ BASICS C++ CHARACTER SET Letters A - Z, a – z Digits 0 -9
Special Symbols Space + - * / ^ \ ( ) [ ] { } = ≠ < > . ‘ “ $ , ; : % ! & ? _ # <= White Spaces Blank space, Horizontal tab (→) carriage return (← ), Newline, Form feed Other characters C++ can process any of the 256 ASCII characters as data or as literals

3 Tokens The smallest individual unit in a program Key words Identifiers
Literals Punctuators Operators

4 KEYWORDS Words that convey special meaning to the language compiler
break case catch char class const continue default delete do double else enum extern float for friend goto if inline integer long new 0perator private protected public register return short signed vsizeof static struct switch template this throw try typedef union unsigned virtual void

5 IDENTIFIERS An arbitrarily long sequence of letters and digits. The first character must be a letter: the underscore ( _) counts as a letter. Upper and lower-case letters are different. All characters are significant

6 VALID / INVALID IDENTIFIERS
DATA-REC 29CLCT BREAK MY.FILE Myfile _CHK DATE9_7_77 MYFILE Z2TOZ9

7 LITERALS Data items that never change their value
during a program run. integer– constants character–constant floating–constant string–constant

8 INTEGER CONSTANTS An integer constant must have at least one digit and must not contain any decimal point. It may contain either + or - sign . A number with no sign is assumed to be positive. Commas cannot appear in an integer constant

9 TYPES OF INTEGER CONSTANT
Decimal Integer Constants (base10) Eg. 1234, 41, +97, - 12 Octal Integer Constants (base 8) Eg. 034, 071 etc.,( digits between 0 – 7 only) Hexadecimal Integer Constants (base 16) Eg. OCX etc.,

10 CHARACTER CONSTANT It must contain one character enclosed in single quotation marks Eg. ‘z’, ‘m’ etc.,

11 ESCAPE SEQUENCE IN C++ Escape Sequence Nongraphic Character \a
Audible Bell (alert) \b Backspace \f Formfeed \n Newline or linefeed \r Carriage Return \t Horizontal tab \v Vertical Tab \\ Backslash \On Octal number (On represents the number in octal) \0 Null

12 FLOATING CONSTANT OR REAL CONSTANTS
In fraction form Must have at least one digit before a decimal point and at least one digit after the decimal point. It may have either positive or negative sign preceding. By default with no sign it is positive. In Exponent form It has two parts : a mantissa and an exponent. The mantissa must be either an integer or a proper real constant. The exponent must be an integer. The mantissa is followed by a letter E

13 Valid / Nonvalid Real constants
In fraction form In Exponent form Valid Invalid Valid Invalid 2.0 7 152E05 172.E5 17.5 7 1.52E07 1.7E -13.0 0.1523E08 0.17E2.3 17,230.50 152.0E08 .25E-7

14 It is a sequence of characters surrounded by double quotes
STRING LITERALS It is a sequence of characters surrounded by double quotes

15 Diagrammatic representation
Literals Integer Constan t Character Constan t Floating Constan t String Literal Decimal Octal Hexa Decimal

16 PUNCTUATORS/ SEPERATORS
[ ] ( ) { } , : ; * … = #

17 OPERATORS These are tokens that trigger some computation or action when applied to variables and other objects in an expression

18 Diagrammatic representation
Token Keywords Identifiers Literals Punctuators Operators Integer Constant Character Constant Floating Constant String Literal Decimal Octal Hexa Decima l

19


Download ppt "C++ Basics."

Similar presentations


Ads by Google