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.
Session 2
Session Objectives <ul><ul><li>Identify the C++ character set </li></ul></ul><ul><ul><li>Discuss the identifiers and keywo...
Introduction Identifier
C++ Character set
Special characters [ ] ( ) . -> ++ -- & * + - ~ !  / % << >> < > <= >= == != ^ && | || ?: = *= /= %= += -= <<= >>= &= ^= |...
Escape sequences (1) Back space New line Tab
Escape sequences (2) Carriage return Form feed Single quote
Escape sequences (3) Back slash Bell Octal number  given by  ooo Hexadecimal number   given by   hh
Escape sequences (4) #include <iostream.h> #include <conio.h>   void main(void) { clrscr();//This function is used to clea...
Identifiers (1) Variables functions labels User defined objects
Identifiers (2) First character =  alphabet Subsequent = characters   or   underscore alphabets numbers or underscores
Identifiers (3) Follow Standard naming convention Name should define the purpose of existence Use prefixes and suffixes Re...
Identifiers (4) Of an identifier is the part of the program  where the identifier is recognized
Keywords New in C++
Data Types and Variables
Pre-defined Data Types Type Description Length char  Single letter character entries only   8 bits   int (short) Integer v...
Declaring variables data_type variable name = initial value optional int  num  ; int  num1  = 3; char   alpha  =  ‘G’  ; f...
Character strings char   str_string [6]   ; char   str_string [30]=   “ Nice Day “   ;
Variable qualifiers
Type modifiers long signed unsigned short…. long   int  var1  ; Unsigned short   int   var2  ;
Access modifiers const   float   pi   = 3.146 ; const   char   three   =  ‘3’ ; const   int   number   = 5 ; const   doubl...
Constants (1)
Constants (2)  const   int  a   =   41   ;  // decimal  const int  b   =  0345   ; // octal begin with 0 const int   c   =...
Constants (3)  //Defining a standard decimal value const float   f_number   =  12.5766   ;   Either the whole part of the ...
Constants (4)  Const double  d_const_val   =9.43E-99   ;   Mantissa in decimal notation Followed by letter ‘ e ’ or ‘ E ‘
Constants (5)  const   char  c_alpha   =   ‘A’   ;
Constants (6)
Constants (7)  #include <iostream.h>   void main(void) { // Defining a string constant   const char   str_message[ ]   =  ...
Upcoming SlideShare
Loading in …5
×

C++ Session 2

928 views

Published on

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

  • Be the first to like this

C++ Session 2

  1. 1. Session 2
  2. 2. Session Objectives <ul><ul><li>Identify the C++ character set </li></ul></ul><ul><ul><li>Discuss the identifiers and keywords </li></ul></ul><ul><ul><li>Explain various data types and qualifiers </li></ul></ul><ul><ul><li>Identify the C++ variables </li></ul></ul>
  3. 3. Introduction Identifier
  4. 4. C++ Character set
  5. 5. Special characters [ ] ( ) . -> ++ -- & * + - ~ ! / % << >> < > <= >= == != ^ && | || ?: = *= /= %= += -= <<= >>= &= ^= |= , # ##
  6. 6. Escape sequences (1) Back space New line Tab
  7. 7. Escape sequences (2) Carriage return Form feed Single quote
  8. 8. Escape sequences (3) Back slash Bell Octal number given by ooo Hexadecimal number given by hh
  9. 9. Escape sequences (4) #include <iostream.h> #include <conio.h>   void main(void) { clrscr();//This function is used to clear the screen cout << &quot;Using the newline escape sequence. &quot; ; cout<<&quot;To use backspace escape sequence,press enter&quot; ; getch() ;//This function is used to pause for user entry cout << &quot;Used backspace&quot; ; cout << &quot; Using the tab sequence tab here&quot; ; getch() ; } To use backspace escape sequence, press enter To use backspace escape sequence, Used backspace Using the tab sequence tab here
  10. 10. Identifiers (1) Variables functions labels User defined objects
  11. 11. Identifiers (2) First character = alphabet Subsequent = characters or underscore alphabets numbers or underscores
  12. 12. Identifiers (3) Follow Standard naming convention Name should define the purpose of existence Use prefixes and suffixes Referring is easier Avoid using u,i,j… Leads to confusion
  13. 13. Identifiers (4) Of an identifier is the part of the program where the identifier is recognized
  14. 14. Keywords New in C++
  15. 15. Data Types and Variables
  16. 16. Pre-defined Data Types Type Description Length char Single letter character entries only 8 bits int (short) Integer values only 16 bits long Accepts higher range of integer values than the int data type 32 bits float Supports decimal point notation 32 bits double Supports decimal point notation with greater precision than Float data type 64 bits double float Similar to a float, with greater precision to the right of the decimal point 128 bits void Does not return any value. N/A
  17. 17. Declaring variables data_type variable name = initial value optional int num ; int num1 = 3; char alpha = ‘G’ ; float float_no ; float floa = 33.33; double d_no ; double doub = 1234.121212121 ;
  18. 18. Character strings char str_string [6] ; char str_string [30]= “ Nice Day “ ;
  19. 19. Variable qualifiers
  20. 20. Type modifiers long signed unsigned short…. long int var1 ; Unsigned short int var2 ;
  21. 21. Access modifiers const float pi = 3.146 ; const char three = ‘3’ ; const int number = 5 ; const double d_number = 8738478.9898 ;
  22. 22. Constants (1)
  23. 23. Constants (2) const int a = 41 ; // decimal const int b = 0345 ; // octal begin with 0 const int c = 0x9f ; // hexadecimal begin // with 0x
  24. 24. Constants (3) //Defining a standard decimal value const float f_number = 12.5766 ; Either the whole part of the number or the decimal part can be omitted …but not both
  25. 25. Constants (4) Const double d_const_val =9.43E-99 ; Mantissa in decimal notation Followed by letter ‘ e ’ or ‘ E ‘
  26. 26. Constants (5) const char c_alpha = ‘A’ ;
  27. 27. Constants (6)
  28. 28. Constants (7) #include <iostream.h>   void main(void) { // Defining a string constant   const char str_message[ ] = “All done“ ; cout << str_message ; } “ All done“

×