Your SlideShare is downloading. ×
C++ Session 2
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

C++ Session 2

632
views

Published on

Published in: Education, Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
632
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
42
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Session 2
  • 2. Session Objectives
      • Identify the C++ character set
      • Discuss the identifiers and keywords
      • Explain various data types and qualifiers
      • Identify the C++ variables
  • 3. Introduction Identifier
  • 4. C++ Character set
  • 5. Special characters [ ] ( ) . -> ++ -- & * + - ~ ! / % << >> < > <= >= == != ^ && | || ?: = *= /= %= += -= <<= >>= &= ^= |= , # ##
  • 6. Escape sequences (1) Back space New line Tab
  • 7. Escape sequences (2) Carriage return Form feed Single quote
  • 8. Escape sequences (3) Back slash Bell Octal number given by ooo Hexadecimal number given by hh
  • 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. Identifiers (1) Variables functions labels User defined objects
  • 11. Identifiers (2) First character = alphabet Subsequent = characters or underscore alphabets numbers or underscores
  • 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. Identifiers (4) Of an identifier is the part of the program where the identifier is recognized
  • 14. Keywords New in C++
  • 15. Data Types and Variables
  • 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. 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. Character strings char str_string [6] ; char str_string [30]= “ Nice Day “ ;
  • 19. Variable qualifiers
  • 20. Type modifiers long signed unsigned short…. long int var1 ; Unsigned short int var2 ;
  • 21. Access modifiers const float pi = 3.146 ; const char three = ‘3’ ; const int number = 5 ; const double d_number = 8738478.9898 ;
  • 22. Constants (1)
  • 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. 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. Constants (4) Const double d_const_val =9.43E-99 ; Mantissa in decimal notation Followed by letter ‘ e ’ or ‘ E ‘
  • 26. Constants (5) const char c_alpha = ‘A’ ;
  • 27. Constants (6)
  • 28. Constants (7) #include <iostream.h>   void main(void) { // Defining a string constant   const char str_message[ ] = “All done“ ; cout << str_message ; } “ All done“