Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

C++

1,443 views

Published on

Published in: Education, Spiritual, Technology
  • Be the first to comment

  • Be the first to like this

C++

  1. 1. C++ INTRODUCTION AND TOKENS<br />Made by:<br /> RAFIYA SIRIN<br /> XI-B<br />
  2. 2. C++ INTRODUCTION<br />C++ was developed by Bjarne Stroustrup of AT&T Bell Laboratories in the early 1980&apos;s, and is based on the C language. The name is a pun - &quot;++&quot; is a syntactic construct used in C and C++ is intended as an incremental improvement of C. Most of C is subset of C++, so that most C programs can be compiled (i.e. converted into a series of low-level instructions that the computer can execute directly) using a C++ compiler.<br />The name C++ was coined by Rick Mascitti. Ever since it’s birth it has coped up with problems encountered by users, and through discussions at AT&T. however the maturation of the C++ language is attested to by two recent events:<br />(i) the formation of American National Standard Institute) C++ committee <br />(ii) the publication of The Annotated C++ Reference Manual by Ellis and Stroustrup.<br />
  3. 3. Because C++ retains C as a subset, it gains many of the attractive features of the C language, such as efficiency, closeness to the machine, and a variety of built-in types. A number of new features were added to C++ to make the language even more robust, many of which are not used by novice programmers. By introducing these new features here, we hope that you will begin to use them in your own programs early on and gain their benefits. Some of the features we will look at are the role of constants, inline expansion, references, declaration statements, user defined types, overloading, and the free store. <br />
  4. 4. THE SMALLEST INDIVIDUAL UNIT IN A PROGRAM IS KNOWN AS A TOKEN OR A LEXICAL UNIT<br />TOKENS<br />
  5. 5. KEYWORDS<br />IDENTIFIERS<br />TOKENS<br />LITERALS<br />PUNCTUATORS<br />OPERATORS<br />
  6. 6. KEYWORDS<br />In computer programming, a keyword is a word or identifier that has a particular meaning to the programming language. The meaning of keywords — and, indeed, the meaning of the notion of keyword — differs widely from language to language.<br /> <br />In many languages, such as C and similar environments like C++, a keyword is a reserved word which identifies a syntactic form. Words used in control flow constructs, such as if, then, and else are keywords. In these languages, keywords can also be used as the names of variables or functions.<br />
  7. 7. C++ KEYWORDS<br />
  8. 8. IDENTIFIERS<br />In computer science, Identifiers (IDs) are lexical tokens that name entities. The concept is analogous to that of a &quot;name.&quot; Identifiers are used extensively in virtually all information processing systems. Naming entities makes it possible to refer to them, which is essential for any kind of symbolic processing.<br />Computer languages usually place restrictions on what characters may appear in an identifier. For example, in early versions the C and C++ language, identifiers are restricted to being a sequence of one or more ASCII letters, digits (these may not appear as the first character), and underscores. Later versions of these languages, along with many other modern languages support almost all Unicode characters in an identifier (a common restriction is not to permit white space characters and language operators).<br />
  9. 9. RULES FOR DETERMING AN IDENTIFIER<br />First character must be a letter<br />After that any combination of letters and digits can be taken.<br />Only underscore can be included and must be treated as a letter.<br />Keywords cannot be used as identifiers. <br />
  10. 10. SOME VALID AND INVALID IDENTIFIERS<br />VALID:- My file DATE9_7_77 Z2T0Z9<br /> MYFILE _DS _HJI3_JK<br /> _CHK FILE13<br />INVALID:- DATA-REC contains special character<br /> 29CLCT starting with a digit<br /> break reserved keyword<br /> My.file contains special character<br />
  11. 11. LITERALS<br />In computer science, a literal is a notation for representing a fixed value in source code. Almost all programming languages have notations for atomic values such as integers, floating-point numbers, strings, and Booleans; some also have notations for elements of enumerated types and compound values such as arrays, records, and objects. <br />Literals are divided into four types:<br />integer-constant<br /> character- constant<br />Floating constant<br />String-literal<br />
  12. 12. INTEGER CONSTANTS<br />They are whole numbers without any fractional parts. the method of writing integer constants has been specified in following rule:-<br /> 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. This again has three types: (i)decimal(base 10)<br />(ii)octal(base 8)<br />(iii)hexadecimal(base 16)<br />
  13. 13. CHARACTER CONSTANT<br />A character constant is one character enclosed in single quotes, as in ‘z’. The rule for writing character constant is given below:-<br /> a character constant is C++must contain one character and must be enclosed in single quotation marks.<br />C++ allows us to have certain non-graphic characters. These cannot be typed directly from keyboard. E.g., backspace, tabs, carriage, return etc.<br />
  14. 14. ESCAPE SEQUENCE<br />
  15. 15. FLOATING CONSTANTS<br />Floating constants are also called real constants.<br />Real constants are functions having fractional parts. These may be written in one of the two forms called fractional form or the exponent form. It consists of signed or unsigned digits including a decimal point between digits. The rule for writing a real constant is:-<br />A real constant in fractional form must have at least one digit after the decimal point. It may also have either + or – sign preceding it. A real constant with no sign is assumed to be positive.<br />
  16. 16. STRING LITERALS:-<br />Multiple character constants are treated as string- literals. The rule for writing string-literal is given below:-<br />A string literal is a sequence of characters surrounded by double quotes.<br />Specifically, most string literals can be specified using:<br /> <br />declarative notation; <br />whitespace delimiters (indentation); <br />bracketed delimiters (quoting); <br />escape characters; or <br />a combination of some or all of the above <br />
  17. 17. PUNCTUATORS<br />A punctuator is a token that has syntactic and semantic meaning to the compiler, but the exact significance depends on the context. A punctuator can also be a token that is used in the syntax of the preprocessor.<br />
  18. 18.
  19. 19. OPERATORS<br />Operators are tokens that trigger some computation when applied to variables and other objects in an expression. The following list gives a brief description of the operators and their functions.<br />Unary operators require one operand to operate upon.<br />Binary operators require two operands to operate upon.<br />
  20. 20.
  21. 21. ORDER OF PRECEDENCE<br />( ) [ ] <br />! ~ + - ++ -- & *(typeset)<br />* / %<br />+ - <br />&lt;&lt; &gt;&gt;<br />&lt; &lt;= !=<br />&<br />^ <br />I<br />&&<br />II<br />?:<br />= *= / %= += -= &= ^= I= &lt; &lt;= &gt; &gt;=<br />
  22. 22. THANK YOU<br />

×