1 / 14

BASIC CONCEPT OF C++

BASIC CONCEPT OF C++. Topics to be discussed……………….. Keywords Identifiers Constants. Keywords

jhutchison
Download Presentation

BASIC CONCEPT OF C++

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. BASIC CONCEPT OF C++

  2. Topics to be discussed……………….. Keywords Identifiers Constants

  3. Keywords The keywords implement specific C++ language features. They are explicitly reserve identifiers and cannot be used as names for the program variables or other user defined program elements. The keywords are also known as Reserve Words. For example: auto double new switch break else operator template continue inline protected try default struct virtual static

  4. Identifier Identifiers refer to the names of variables, functions, arrays, classes etc. created by the programmer. They are fundamental requirement of any language. Each language has its own rules for naming these identifiers. The following rules are used for identifiers: Only alphabetic characters, digits and underscore are permitted. • The name cannot start with a digit. • Uppercase and lowercase letters are distinct. • A declared keyword cannot be used as a name

  5. Constants Constants refer to fixed values that do not change during the execution of a program. Constants Character Constants Numeric Constants Integer Constants Real Constants Single Character Constants String constants

  6. Integer Constant An integer constant refers to a sequence of digits without decimal point. Rules for constructing integer constants are: • An integer constant must have at least one digit. • An integer constant contains neither a decimal point nor an exponent. • Commas and blank space cannot be included within the number. • Sign must precede the number. • Default sign is positive. • The allowable range for integer constants for 16 bit computer is -32768 to 32767

  7. Types of Integer Constants • Decimal • Octal • Hexadecimal Decimal Integer: Decimal integer consists of a set of digits 0 through 9.Following are decimal integer constants: 18, -11, 56, 0, 546 On the other hand, the following are not valid integer constants : 25.0 contains a decimal point 12,250 contains a comma 5- sign does not precede 20 30 blank spaces are not allowed

  8. Octal Integer : An octal integer constants consists of any combination of digits from 0 through 7, with leading 0 (Zero).The following are valid octal integer constants: 015 0475 0 0764 Hexadecimal Integer Constant: A hexadecimal integer constants consist of any combination of digits from 0 through 9 or alphabets a (or A) through f(or F), with a leading 0x or 0X. The following are valid hexadecimal integer constants: 0x5 0x7ab 0xabc 0x975

  9. Real Constants Real constants are also called floating point constants. A real constant is a number that contains either a decimal point or an exponent. The real constants could be written in two forms – Fractional form and Exponential form.

  10. Fractional form Real Constants Rules for constructing integer constants are: • A real constant must have at least one digit. • An real constant must contain a decimal point • Commas and blank space cannot be included within the number. • Sign must precede the number. • Default sign is positive. Following are the valid real constants 35.5 0.045

  11. Exponential form Real Constants The general form of real constants expressed in exponential form is mantissa e exponent Rules for Real Constants in exponential form are: • The mantissa is either a real number expressed in decimal notation or an integer. • The exponent is always an integer number with an optional plus or minus sign. • The mantissa part many have a (+) or (-) sign. Default sign is (+) positive. • The mantissa part and the exponential part should be separated by a letter “e”. • No commas or blank spaces are allowed • Range of real constants expressed in exponential form is -3.4e-38 to 3.4e38.

  12. The following are the valid real constants expressed in exponential form: 0.5e3 -1.2e-7 1.5e+9 Following are not valid Real Constants: 25,000.0 , is not allowed 35 Either a decimal point or an exponent must be present. 125e4.5 exponent must be an integer. $425e-15 $ symbol is not permitted.

  13. Single Character Constant A single character constant is a single character, enclosed in apostrophes(single quotation marks). The character may be a letter, number, or special character. Example ‘a’ ‘:’ ‘5’ String Constants A string constant is a sequence of characters enclosed in double quotes. String constants automatically end with null character “\0”. Therefore, the string “DAV” will automatically be represented as “DAV\0” in the memory and its size is not 3 but 4 characters.

  14. THANKS

More Related