SlideShare uma empresa Scribd logo
1 de 21
Object Oriented Programming: 8
Basics of C++ Programming
Prof Neeraj Bhargava
Vaibhav Khanna
Department of Computer Science
School of Engineering and Systems Sciences
Maharshi Dayanand Saraswati University Ajmer
2
The Basics of a C++ Program
• Function: collection of statements; when
executed, accomplishes something
– May be predefined or standard
• Syntax: rules that specify which statements
(instructions) are legal
• Programming language: a set of rules,
symbols, and special words
• Semantic rule: meaning of the instruction
3
Comments
• Comments are for the reader, not the compiler
• Two types:
– Single line
// This is a C++ program. It prints the sentence:
// Welcome to C++ Programming.
– Multiple line
/*
You can include comments that can
occupy several lines.
*/
4
Special Symbols
• Special symbols
+
-
*
/
.
;
?
,
<=
!=
==
>=
5
Reserved Words (Keywords)
• Reserved words, keywords, or word symbols
– Include:
• int
• float
• double
• char
• const
• void
• return
6
Identifiers
• Consist of letters, digits, and the underscore
character (_)
• Must begin with a letter or underscore
• C++ is case sensitive
– NUMBER is not the same as number
• Two predefined identifiers are cout and cin
• Unlike reserved words, predefined identifiers
may be redefined, but it is not a good idea
7
Identifiers (continued)
• The following are legal identifiers in C++:
– first
– conversion
– payRate
8
Whitespaces
• Every C++ program contains whitespaces
– Include blanks, tabs, and newline characters
• Used to separate special symbols, reserved
words, and identifiers
• Proper utilization of whitespaces is important
– Can be used to make the program readable
9
Data Types
• Data type: set of values together with a set of
operations
• C++ data types fall into three categories:
10
Simple Data Types
• Three categories of simple data
– Integral: integers (numbers without a decimal)
– Floating-point: decimal numbers
– Enumeration type: user-defined data type
11
Simple Data Types (continued)
• Integral data types are further classified into
nine categories:
12
Simple Data Types (continued)
• Different compilers may allow different ranges
of values
13
int Data Type
• Examples:
-6728
0
78
+763
• Positive integers do not need a + sign
• No commas are used within an integer
– Commas are used for separating items in a list
14
bool Data Type
• bool type
– Two values: true and false
– Manipulate logical (Boolean) expressions
• true and false are called logical values
• bool, true, and false are reserved words
15
char Data Type
• The smallest integral data type
• Used for characters: letters, digits, and special
symbols
• Each character is enclosed in single quotes
– 'A', 'a', '0', '*', '+', '$', '&'
• A blank space is a character and is written '
', with a space left between the single quotes
16
• C++ uses scientific notation to represent real
numbers (floating-point notation)
Floating-Point Data Types
17
Floating-Point Data Types (continued)
– float: represents any real number
• Range: -3.4E+38 to 3.4E+38 (four bytes)
– double: represents any real number
• Range: -1.7E+308 to 1.7E+308 (eight bytes)
– On most newer compilers, data types double
and long double are same
18
Floating-Point Data Types (continued)
• Maximum number of significant digits
(decimal places) for float values is 6 or 7
• Maximum number of significant digits for
double is 15
• Precision: maximum number of significant
digits
– Float values are called single precision
– Double values are called double precision
19
Arithmetic Operators and Operator
Precedence
• C++ arithmetic operators:
– + addition
– - subtraction
– * multiplication
– / division
– % modulus operator
• +, -, *, and / can be used with integral and
floating-point data types
• Operators can be unary or binary
20
Order of Precedence
• All operations inside of () are evaluated first
• *, /, and % are at the same level of
precedence and are evaluated next
• + and – have the same level of precedence
and are evaluated last
• When operators are on the same level
– Performed from left to right (associativity)
• 3 * 7 - 6 + 2 * 5 / 4 + 6 means
(((3 * 7) – 6) + ((2 * 5) / 4 )) + 6
Assignment
• Discuss in detail the rules related to Identifiers
in C++
• What are the data types available in C++

Mais conteúdo relacionado

Mais procurados

constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
Sahithi Naraparaju
 
Numbersystem 130621192712-phpapp02
Numbersystem 130621192712-phpapp02Numbersystem 130621192712-phpapp02
Numbersystem 130621192712-phpapp02
muhammadsarab
 

Mais procurados (19)

Decimal, Binary, Octal, And Hexadecimal number systems.
Decimal, Binary, Octal, And Hexadecimal number systems.Decimal, Binary, Octal, And Hexadecimal number systems.
Decimal, Binary, Octal, And Hexadecimal number systems.
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
 
Object oriented programming 13 input stream and devices in cpp
Object oriented programming 13 input stream and devices in cppObject oriented programming 13 input stream and devices in cpp
Object oriented programming 13 input stream and devices in cpp
 
Gates and Flip flop
Gates and Flip flopGates and Flip flop
Gates and Flip flop
 
Introduction to binary number system
Introduction to binary number systemIntroduction to binary number system
Introduction to binary number system
 
Number Systems
Number SystemsNumber Systems
Number Systems
 
Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2Datatype in c++ unit 3 -topic 2
Datatype in c++ unit 3 -topic 2
 
Object oriented programming 11 preprocessor directives and program structure
Object oriented programming 11 preprocessor directives and program structureObject oriented programming 11 preprocessor directives and program structure
Object oriented programming 11 preprocessor directives and program structure
 
C programming Tutorial Session 1
C programming Tutorial Session 1C programming Tutorial Session 1
C programming Tutorial Session 1
 
Numeric Data Types & Strings
Numeric Data Types & StringsNumeric Data Types & Strings
Numeric Data Types & Strings
 
2 expressions (ppt-2) in C++
2 expressions (ppt-2) in C++2 expressions (ppt-2) in C++
2 expressions (ppt-2) in C++
 
Computer Programming
Computer ProgrammingComputer Programming
Computer Programming
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
 
Data types
Data typesData types
Data types
 
Data types
Data typesData types
Data types
 
Cp presentation
Cp presentationCp presentation
Cp presentation
 
Numbersystem 130621192712-phpapp02
Numbersystem 130621192712-phpapp02Numbersystem 130621192712-phpapp02
Numbersystem 130621192712-phpapp02
 
Computerarchitecture by csa
Computerarchitecture by csaComputerarchitecture by csa
Computerarchitecture by csa
 
Programming construction tools
Programming construction toolsProgramming construction tools
Programming construction tools
 

Semelhante a Object oriented programming 8 basics of c++ programming

Chap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptxChap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptx
Ronaldo Aditya
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
Tony Apreku
 

Semelhante a Object oriented programming 8 basics of c++ programming (20)

Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
C++ ch2
C++ ch2C++ ch2
C++ ch2
 
Chap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptxChap_________________1_Introduction.pptx
Chap_________________1_Introduction.pptx
 
PPT slide_chapter 02 Basic element of C++.ppt
PPT slide_chapter 02 Basic element of C++.pptPPT slide_chapter 02 Basic element of C++.ppt
PPT slide_chapter 02 Basic element of C++.ppt
 
C++.ppt
C++.pptC++.ppt
C++.ppt
 
9781285852744 ppt ch02
9781285852744 ppt ch029781285852744 ppt ch02
9781285852744 ppt ch02
 
Basic elements of java
Basic elements of java Basic elements of java
Basic elements of java
 
programming week 2.ppt
programming week 2.pptprogramming week 2.ppt
programming week 2.ppt
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
 
5 conceptos progamacion2-tema4
5 conceptos progamacion2-tema45 conceptos progamacion2-tema4
5 conceptos progamacion2-tema4
 
INTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c languageINTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c language
 
Data structure Unit-I Part A
Data structure Unit-I Part AData structure Unit-I Part A
Data structure Unit-I Part A
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
C programming language
C programming languageC programming language
C programming language
 
1.4 Work with data types and variables, numeric data, string data.pptx
1.4 Work with data types and variables, numeric data, string data.pptx1.4 Work with data types and variables, numeric data, string data.pptx
1.4 Work with data types and variables, numeric data, string data.pptx
 
B.sc CSIT 2nd semester C++ Unit2
B.sc CSIT  2nd semester C++ Unit2B.sc CSIT  2nd semester C++ Unit2
B.sc CSIT 2nd semester C++ Unit2
 
Basic Elements of C++
Basic Elements of C++Basic Elements of C++
Basic Elements of C++
 
20BCT23 – PYTHON PROGRAMMING.pptx
20BCT23 – PYTHON PROGRAMMING.pptx20BCT23 – PYTHON PROGRAMMING.pptx
20BCT23 – PYTHON PROGRAMMING.pptx
 
#Code2 create c++ for beginners
#Code2 create  c++ for beginners #Code2 create  c++ for beginners
#Code2 create c++ for beginners
 
C cpluplus 2
C cpluplus 2C cpluplus 2
C cpluplus 2
 

Mais de Vaibhav Khanna

Mais de Vaibhav Khanna (20)

Information and network security 47 authentication applications
Information and network security 47 authentication applicationsInformation and network security 47 authentication applications
Information and network security 47 authentication applications
 
Information and network security 46 digital signature algorithm
Information and network security 46 digital signature algorithmInformation and network security 46 digital signature algorithm
Information and network security 46 digital signature algorithm
 
Information and network security 45 digital signature standard
Information and network security 45 digital signature standardInformation and network security 45 digital signature standard
Information and network security 45 digital signature standard
 
Information and network security 44 direct digital signatures
Information and network security 44 direct digital signaturesInformation and network security 44 direct digital signatures
Information and network security 44 direct digital signatures
 
Information and network security 43 digital signatures
Information and network security 43 digital signaturesInformation and network security 43 digital signatures
Information and network security 43 digital signatures
 
Information and network security 42 security of message authentication code
Information and network security 42 security of message authentication codeInformation and network security 42 security of message authentication code
Information and network security 42 security of message authentication code
 
Information and network security 41 message authentication code
Information and network security 41 message authentication codeInformation and network security 41 message authentication code
Information and network security 41 message authentication code
 
Information and network security 40 sha3 secure hash algorithm
Information and network security 40 sha3 secure hash algorithmInformation and network security 40 sha3 secure hash algorithm
Information and network security 40 sha3 secure hash algorithm
 
Information and network security 39 secure hash algorithm
Information and network security 39 secure hash algorithmInformation and network security 39 secure hash algorithm
Information and network security 39 secure hash algorithm
 
Information and network security 38 birthday attacks and security of hash fun...
Information and network security 38 birthday attacks and security of hash fun...Information and network security 38 birthday attacks and security of hash fun...
Information and network security 38 birthday attacks and security of hash fun...
 
Information and network security 37 hash functions and message authentication
Information and network security 37 hash functions and message authenticationInformation and network security 37 hash functions and message authentication
Information and network security 37 hash functions and message authentication
 
Information and network security 35 the chinese remainder theorem
Information and network security 35 the chinese remainder theoremInformation and network security 35 the chinese remainder theorem
Information and network security 35 the chinese remainder theorem
 
Information and network security 34 primality
Information and network security 34 primalityInformation and network security 34 primality
Information and network security 34 primality
 
Information and network security 33 rsa algorithm
Information and network security 33 rsa algorithmInformation and network security 33 rsa algorithm
Information and network security 33 rsa algorithm
 
Information and network security 32 principles of public key cryptosystems
Information and network security 32 principles of public key cryptosystemsInformation and network security 32 principles of public key cryptosystems
Information and network security 32 principles of public key cryptosystems
 
Information and network security 31 public key cryptography
Information and network security 31 public key cryptographyInformation and network security 31 public key cryptography
Information and network security 31 public key cryptography
 
Information and network security 30 random numbers
Information and network security 30 random numbersInformation and network security 30 random numbers
Information and network security 30 random numbers
 
Information and network security 29 international data encryption algorithm
Information and network security 29 international data encryption algorithmInformation and network security 29 international data encryption algorithm
Information and network security 29 international data encryption algorithm
 
Information and network security 28 blowfish
Information and network security 28 blowfishInformation and network security 28 blowfish
Information and network security 28 blowfish
 
Information and network security 27 triple des
Information and network security 27 triple desInformation and network security 27 triple des
Information and network security 27 triple des
 

Último

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Último (20)

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 

Object oriented programming 8 basics of c++ programming

  • 1. Object Oriented Programming: 8 Basics of C++ Programming Prof Neeraj Bhargava Vaibhav Khanna Department of Computer Science School of Engineering and Systems Sciences Maharshi Dayanand Saraswati University Ajmer
  • 2. 2 The Basics of a C++ Program • Function: collection of statements; when executed, accomplishes something – May be predefined or standard • Syntax: rules that specify which statements (instructions) are legal • Programming language: a set of rules, symbols, and special words • Semantic rule: meaning of the instruction
  • 3. 3 Comments • Comments are for the reader, not the compiler • Two types: – Single line // This is a C++ program. It prints the sentence: // Welcome to C++ Programming. – Multiple line /* You can include comments that can occupy several lines. */
  • 4. 4 Special Symbols • Special symbols + - * / . ; ? , <= != == >=
  • 5. 5 Reserved Words (Keywords) • Reserved words, keywords, or word symbols – Include: • int • float • double • char • const • void • return
  • 6. 6 Identifiers • Consist of letters, digits, and the underscore character (_) • Must begin with a letter or underscore • C++ is case sensitive – NUMBER is not the same as number • Two predefined identifiers are cout and cin • Unlike reserved words, predefined identifiers may be redefined, but it is not a good idea
  • 7. 7 Identifiers (continued) • The following are legal identifiers in C++: – first – conversion – payRate
  • 8. 8 Whitespaces • Every C++ program contains whitespaces – Include blanks, tabs, and newline characters • Used to separate special symbols, reserved words, and identifiers • Proper utilization of whitespaces is important – Can be used to make the program readable
  • 9. 9 Data Types • Data type: set of values together with a set of operations • C++ data types fall into three categories:
  • 10. 10 Simple Data Types • Three categories of simple data – Integral: integers (numbers without a decimal) – Floating-point: decimal numbers – Enumeration type: user-defined data type
  • 11. 11 Simple Data Types (continued) • Integral data types are further classified into nine categories:
  • 12. 12 Simple Data Types (continued) • Different compilers may allow different ranges of values
  • 13. 13 int Data Type • Examples: -6728 0 78 +763 • Positive integers do not need a + sign • No commas are used within an integer – Commas are used for separating items in a list
  • 14. 14 bool Data Type • bool type – Two values: true and false – Manipulate logical (Boolean) expressions • true and false are called logical values • bool, true, and false are reserved words
  • 15. 15 char Data Type • The smallest integral data type • Used for characters: letters, digits, and special symbols • Each character is enclosed in single quotes – 'A', 'a', '0', '*', '+', '$', '&' • A blank space is a character and is written ' ', with a space left between the single quotes
  • 16. 16 • C++ uses scientific notation to represent real numbers (floating-point notation) Floating-Point Data Types
  • 17. 17 Floating-Point Data Types (continued) – float: represents any real number • Range: -3.4E+38 to 3.4E+38 (four bytes) – double: represents any real number • Range: -1.7E+308 to 1.7E+308 (eight bytes) – On most newer compilers, data types double and long double are same
  • 18. 18 Floating-Point Data Types (continued) • Maximum number of significant digits (decimal places) for float values is 6 or 7 • Maximum number of significant digits for double is 15 • Precision: maximum number of significant digits – Float values are called single precision – Double values are called double precision
  • 19. 19 Arithmetic Operators and Operator Precedence • C++ arithmetic operators: – + addition – - subtraction – * multiplication – / division – % modulus operator • +, -, *, and / can be used with integral and floating-point data types • Operators can be unary or binary
  • 20. 20 Order of Precedence • All operations inside of () are evaluated first • *, /, and % are at the same level of precedence and are evaluated next • + and – have the same level of precedence and are evaluated last • When operators are on the same level – Performed from left to right (associativity) • 3 * 7 - 6 + 2 * 5 / 4 + 6 means (((3 * 7) – 6) + ((2 * 5) / 4 )) + 6
  • 21. Assignment • Discuss in detail the rules related to Identifiers in C++ • What are the data types available in C++