SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Variable declaration &
     initialization
• Declaration:
                                  int x;
                                 ↙ ↘
                     data type      identifier name
(for more than one variables separate them with commas)

• Initialization:
                                   x=9;
(value is stored )
• Declaration & initialization in one step:
             int x=9;
• = is an assignment operator
Int x,y=6,z=2;
x=y;             ////x=6
y=z;             ///y=2
z=x;            ///z=6
• Its associativity is right (it means right side of =(assignment
  operator )is evaluated first.)
Keywords/reserve words:
• Lower case letters
• E.g for,while,int,char,float
Variable:
• It can be modified. they are used to store constant values
• int→2 bytes        e.g 1,2,3 etc
• float → 4 bytes        e.g 1.1,2.3 etc
• char →1 byte         e.g A,S,D, 1 ,2,3, +,*,& etc
#include<iostream.h>
main()
{
cout<<“hello” ;
}
Operators
• Is anything that perform some action on some variable or constant
1.Unary operators
2.Binary operators
3.Arithmatic operators
1.Unary operators:
++, -- ,+ , -
They increment the value by 1.
(a)Unary minus operator:-
It is used to reverse the sign of a value.it makes a +ve value to –ve value and
     vice versa.e.g
int a, b;
a=87;
b=-a;
It has higher precedence over binary operator.
1.Increment operator:
(A)Prefix increment:
b=++a
a=a+1
b=a

(B)postfix increment:
b=a++
b=a
a=a+1
2.Decrement operator:
(A)Prefix decrement:
--y
b=--a
a=a-1
b=a
(B) postfix decrement:
b=a--
b=a
a=a-1

2.Binary operators:
• The operators that operate on two data items.
• E.g multiplication etc
3.Arithmatic operators: +, - ,* ,/ , %
• Remainder operator :modulus
Order of precedence
•   * , / ………………….left to right
•   + , - ………………….left to right
•   ( ) parenthesis ………………….left to right
•   Parenthesis within parenthesis(innermost first)
•   1+2+3-4+5
•   7+c*d/c
•   a/b/c
•   2+a/b*5
•   6+12/6*2-1
Type casting:
Conversion of one data type of numeric value to
  another
1.Implicit type casting
2.Explicit type casting
Arithmatic expressions:
2(a+b) →2*(a+b)
5/9(F-32) →5/9*(F-32)
Assignment operators: =
• Variable=expression
int a, b, c
a=200 ,b=100
c=a;
a=b;
b=c;
• Compound assignment:
  x=y=6;
Relational operator:
• Also called comparison operator
• After comparing two variables or expressions results into 0
  /1 or true /false
• ==
• !=
• <
• <=
• >
• >=
Logical operator:
1. and operator && (.)
2. or operator || (+)
3. not operator ! (-)
Conditional operator:
• It consists of “?” and “:”.
• Its syntax is
 {condition}?{exp1}:{exp2}
Where
Condition…..represents test condition
Exp1 & exp2….represents two expressions which
  may be arithmetic expression or constant value.
Sizeof operator:
void main()
{
int x;
cout<<sizeof(x);
}

2

Weitere ähnliche Inhalte

Was ist angesagt?

Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional arrayRajendran
 
Chapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-classChapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-classDeepak Singh
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayimtiazalijoono
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : ArraysGagan Deep
 
Introduction to programming with dependent types in Scala
Introduction to programming with dependent types in ScalaIntroduction to programming with dependent types in Scala
Introduction to programming with dependent types in ScalaDmytro Mitin
 
Testing in the World of Functional Programming
Testing in the World of Functional ProgrammingTesting in the World of Functional Programming
Testing in the World of Functional ProgrammingLuka Jacobowitz
 
Lecture17 arrays.ppt
Lecture17 arrays.pptLecture17 arrays.ppt
Lecture17 arrays.ppteShikshak
 
QuickCheck - Software Testing
QuickCheck - Software TestingQuickCheck - Software Testing
QuickCheck - Software TestingJavran
 
Monoids, monoids, monoids
Monoids, monoids, monoidsMonoids, monoids, monoids
Monoids, monoids, monoidsLuka Jacobowitz
 
Multi dimensional array
Multi dimensional arrayMulti dimensional array
Multi dimensional arrayRajendran
 
Principled Error Handling with FP
Principled Error Handling with FPPrincipled Error Handling with FP
Principled Error Handling with FPLuka Jacobowitz
 

Was ist angesagt? (20)

Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
 
Arrays
ArraysArrays
Arrays
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Chapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-classChapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-class
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional array
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
 
Introduction to programming with dependent types in Scala
Introduction to programming with dependent types in ScalaIntroduction to programming with dependent types in Scala
Introduction to programming with dependent types in Scala
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Testing in the World of Functional Programming
Testing in the World of Functional ProgrammingTesting in the World of Functional Programming
Testing in the World of Functional Programming
 
Lecture17 arrays.ppt
Lecture17 arrays.pptLecture17 arrays.ppt
Lecture17 arrays.ppt
 
Lab 13
Lab 13Lab 13
Lab 13
 
Arrays
ArraysArrays
Arrays
 
QuickCheck - Software Testing
QuickCheck - Software TestingQuickCheck - Software Testing
QuickCheck - Software Testing
 
Array in C
Array in CArray in C
Array in C
 
Monoids, monoids, monoids
Monoids, monoids, monoidsMonoids, monoids, monoids
Monoids, monoids, monoids
 
Multi dimensional array
Multi dimensional arrayMulti dimensional array
Multi dimensional array
 
Sigma type
Sigma typeSigma type
Sigma type
 
Templates
TemplatesTemplates
Templates
 
Principled Error Handling with FP
Principled Error Handling with FPPrincipled Error Handling with FP
Principled Error Handling with FP
 

Andere mochten auch

Surface stresses..............................
Surface stresses..............................Surface stresses..............................
Surface stresses..............................Umer Warraich
 
4 pump 03 reciprocating pump
4 pump 03 reciprocating pump4 pump 03 reciprocating pump
4 pump 03 reciprocating pumpRefee Lubong
 
reciprocating pumps
reciprocating pumps  reciprocating pumps
reciprocating pumps THE ROCK
 
Reciprocating pumps
Reciprocating pumpsReciprocating pumps
Reciprocating pumpssumitnp369
 
Reciprocating pump pdf
Reciprocating pump pdfReciprocating pump pdf
Reciprocating pump pdfSourav Jana
 

Andere mochten auch (6)

Surface stresses..............................
Surface stresses..............................Surface stresses..............................
Surface stresses..............................
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
4 pump 03 reciprocating pump
4 pump 03 reciprocating pump4 pump 03 reciprocating pump
4 pump 03 reciprocating pump
 
reciprocating pumps
reciprocating pumps  reciprocating pumps
reciprocating pumps
 
Reciprocating pumps
Reciprocating pumpsReciprocating pumps
Reciprocating pumps
 
Reciprocating pump pdf
Reciprocating pump pdfReciprocating pump pdf
Reciprocating pump pdf
 

Ähnlich wie Lec2+lec3

2nd PUC Computer science chapter 5 review of c++
2nd PUC Computer science chapter 5   review of c++2nd PUC Computer science chapter 5   review of c++
2nd PUC Computer science chapter 5 review of c++Aahwini Esware gowda
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c languageTanmay Modi
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++Neeru Mittal
 
C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till nowAmAn Singh
 
C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till nowAmAn Singh
 
Mesics lecture 4 c operators and experssions
Mesics lecture  4   c operators and experssionsMesics lecture  4   c operators and experssions
Mesics lecture 4 c operators and experssionseShikshak
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptxmohitesoham12
 
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++ Unit2Tekendra Nath Yogi
 
C++ process new
C++ process newC++ process new
C++ process new敬倫 林
 
Introduction to Python Language and Data Types
Introduction to Python Language and Data TypesIntroduction to Python Language and Data Types
Introduction to Python Language and Data TypesRavi Shankar
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructionsLearn By Watch
 
Lec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questionsLec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questionsYashJain47002
 
java Basic Programming Needs
java Basic Programming Needsjava Basic Programming Needs
java Basic Programming NeedsRaja Sekhar
 

Ähnlich wie Lec2+lec3 (20)

2nd PUC Computer science chapter 5 review of c++
2nd PUC Computer science chapter 5   review of c++2nd PUC Computer science chapter 5   review of c++
2nd PUC Computer science chapter 5 review of c++
 
Operators
OperatorsOperators
Operators
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
What is c
What is cWhat is c
What is c
 
C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till now
 
C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till now
 
3.Loops_conditionals.pdf
3.Loops_conditionals.pdf3.Loops_conditionals.pdf
3.Loops_conditionals.pdf
 
C language basics
C language basicsC language basics
C language basics
 
Mesics lecture 4 c operators and experssions
Mesics lecture  4   c operators and experssionsMesics lecture  4   c operators and experssions
Mesics lecture 4 c operators and experssions
 
SPL 6 | Operators in C
SPL 6 | Operators in CSPL 6 | Operators in C
SPL 6 | Operators in C
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.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
 
C++ process new
C++ process newC++ process new
C++ process new
 
Introduction to Python Language and Data Types
Introduction to Python Language and Data TypesIntroduction to Python Language and Data Types
Introduction to Python Language and Data Types
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructions
 
Lec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questionsLec2_cont.pptx galgotias University questions
Lec2_cont.pptx galgotias University questions
 
java Basic Programming Needs
java Basic Programming Needsjava Basic Programming Needs
java Basic Programming Needs
 
Lec19
Lec19Lec19
Lec19
 

Mehr von Umer Warraich (20)

Lec03
Lec03Lec03
Lec03
 
Hydraulic actuator 2003
Hydraulic actuator 2003Hydraulic actuator 2003
Hydraulic actuator 2003
 
Hydraulic fluids(03336275386)
Hydraulic fluids(03336275386)Hydraulic fluids(03336275386)
Hydraulic fluids(03336275386)
 
Hydrauilc systems
Hydrauilc systemsHydrauilc systems
Hydrauilc systems
 
Soldering 2
Soldering 2Soldering 2
Soldering 2
 
Brazing
BrazingBrazing
Brazing
 
Lecture 11
Lecture 11Lecture 11
Lecture 11
 
Lecture 10 copy
Lecture  10   copyLecture  10   copy
Lecture 10 copy
 
Tig welding
Tig weldingTig welding
Tig welding
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
Mig
MigMig
Mig
 
Mig
MigMig
Mig
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
Mig
MigMig
Mig
 
7th lec welding
7th lec   welding7th lec   welding
7th lec welding
 
Sheet metal 3
Sheet metal 3Sheet metal 3
Sheet metal 3
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 

Kürzlich hochgeladen

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Kürzlich hochgeladen (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Lec2+lec3

  • 1. Variable declaration & initialization
  • 2. • Declaration: int x; ↙ ↘ data type identifier name (for more than one variables separate them with commas) • Initialization: x=9; (value is stored )
  • 3. • Declaration & initialization in one step: int x=9; • = is an assignment operator Int x,y=6,z=2; x=y; ////x=6 y=z; ///y=2 z=x; ///z=6
  • 4. • Its associativity is right (it means right side of =(assignment operator )is evaluated first.) Keywords/reserve words: • Lower case letters • E.g for,while,int,char,float Variable: • It can be modified. they are used to store constant values • int→2 bytes e.g 1,2,3 etc • float → 4 bytes e.g 1.1,2.3 etc • char →1 byte e.g A,S,D, 1 ,2,3, +,*,& etc
  • 6. Operators • Is anything that perform some action on some variable or constant 1.Unary operators 2.Binary operators 3.Arithmatic operators 1.Unary operators: ++, -- ,+ , - They increment the value by 1. (a)Unary minus operator:- It is used to reverse the sign of a value.it makes a +ve value to –ve value and vice versa.e.g int a, b; a=87; b=-a; It has higher precedence over binary operator.
  • 7. 1.Increment operator: (A)Prefix increment: b=++a a=a+1 b=a (B)postfix increment: b=a++ b=a a=a+1 2.Decrement operator: (A)Prefix decrement: --y b=--a a=a-1 b=a
  • 8. (B) postfix decrement: b=a-- b=a a=a-1 2.Binary operators: • The operators that operate on two data items. • E.g multiplication etc 3.Arithmatic operators: +, - ,* ,/ , % • Remainder operator :modulus
  • 9. Order of precedence • * , / ………………….left to right • + , - ………………….left to right • ( ) parenthesis ………………….left to right • Parenthesis within parenthesis(innermost first) • 1+2+3-4+5 • 7+c*d/c • a/b/c • 2+a/b*5 • 6+12/6*2-1
  • 10. Type casting: Conversion of one data type of numeric value to another 1.Implicit type casting 2.Explicit type casting Arithmatic expressions: 2(a+b) →2*(a+b) 5/9(F-32) →5/9*(F-32)
  • 11. Assignment operators: = • Variable=expression int a, b, c a=200 ,b=100 c=a; a=b; b=c;
  • 12. • Compound assignment: x=y=6; Relational operator: • Also called comparison operator • After comparing two variables or expressions results into 0 /1 or true /false • == • != • < • <= • > • >=
  • 13. Logical operator: 1. and operator && (.) 2. or operator || (+) 3. not operator ! (-)
  • 14. Conditional operator: • It consists of “?” and “:”. • Its syntax is {condition}?{exp1}:{exp2} Where Condition…..represents test condition Exp1 & exp2….represents two expressions which may be arithmetic expression or constant value.
  • 15. Sizeof operator: void main() { int x; cout<<sizeof(x); } 2