SlideShare uma empresa Scribd logo
1 de 31
 Switch statement Logical Statement Assignment Statement  Computer programming C++
Instructor                                  Sir AamirJamshid
Crew Members AzeemMumtaz SaqibMunawar Hafiz Ashfaq M.ZeeshanArshad
Logical Statements AND operator It is used to evaluate two conditions . It produces true result if both conditions are true It produces false if any one condition is false Symbol:                                  “&&”
Working
Example
Output Enter the first number 1 Enter the second number 0 0
OR operator It is used to evaluate two conditions It produces true if either condition is true  It produces false result if both conditions are false Symbol:                             “| |”
Working
Example
Output  Enter the first number 1 Enter the second number 0 1
Not Operator It is the reverses the result of condition It gives True if condition is false It gives false  if condition is true Symbol:                                 “!”
Example  ≡  File  Edit  Search  Run  Compile  Debug  Project  Options    Window  Help ╔═[■]════════════════════════════ NONAME00.CPP ══════════════════════════1═[↑]═╗ ║#include<iostream.h>                                                          ▲ ║#include<conio.h>                                                             ■ ║void main()                                                                   ▒ ║{                                                                             ▒ ║clrscr();                                                                     ▒ ║int a;                                                                        ▒ ║cout<<"Enter the number"<<endl;                                               ▒ ║cin>>a;                                                                       ▒ ║if(a%2!=0)                                                                    ▒ ║cout<<"the number is odd";                                                    ▒ ║else                                                                          ▒ ║cout<<"the number is even";                                                   ▒ ║getch();                                                                      ▒ ║}                                                                             ▼ ╚═☼════ 14:3 ═════◄■▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒►─┘ ┌────────────────────────────────── Message ─────────────────────────────2─────┐ │•Compiling NONAME00.CPP:                                                      │ │ Linking TCDEF.EXE:                                                           │ │                                                                              │ │                                                                              │ │                                                                              │ └──────────────────────────────────────────────────────────────────────────────┘  F1 Help  Alt-F8 Next Msg  Alt-F7 PrevMsg  Alt-F9 Compile  F9 Make  F10 Menu
Output Enter the number 8 The number is even
Hafiz Ashfaq
Assignment Statement  A statement that assigns a value to a variable is known as assignment statement. The assignment =is used in assignment statement to assign a value or computational result to a variable. The name of variable is written on the left side of assignment operator and the value is written on the right side. The value can be a constant ,variable ,expression or a function.
Syntax	 Variable=Expression Examples A=100; C=a+b; X=c-d+10;
LVALUE & RVALUE An L value is an operand that can be written on the left side of assignment operator=it must always be a single value. An rvalue is an operand that can be written on the right side of assignment statement=. All Lvaues can be used as Rvalues.
Example  ≡  File  Edit  Search  Run  Compile  Debug  Project  Options    Window  Help ╔═[■]════════════════════════════ NONAME00.CPP ══════════════════════════1═[↑]═╗ ║#include<iostream.h>                                                          ▲ ║#include<conio.h>                                                             ■ ║void main()                                                                   ▒ ║{clrscr();                                                                    ▒ ║inta,b;                                                                      ▒ ║a=10;                                                                         ▒ ║b=5;                                                                          ▒ ║cout<<"a+b="<<a+b<<endl;                                                      ▒ ║cout<<"a-b="<<a-b<<endl;                                                      ▒ ║cout<<"a*b="<<a*b<<endl;                                                      ▒ ║cout<<"a/b="<<a/b<<endl;                                                      ▒ ║cout<<"a%b="<<a%b<<endl;                                                      ▒ ║getch();                                                                      ▒ ║}                                                                             ▼ ╚═☼════ 14:2 ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒►─┘ ┌────────────────────────────────── Message ─────────────────────────────2─────┐ │•Compiling NONAME00.CPP:                                                      │ │ Linking NONAME00.EXE:                                                        │ │                                                                              │ │                                                                              │ │                                                                              │ └──────────────────────────────────────────────────────────────────────────────┘  F1 Help  Alt-F8 Next Msg  Alt-F7 PrevMsg  Alt-F9 Compile  F9 Make  F10 Menu
M.ZeeshanArshad
Example
Output a+b=15 a-b=5 a*b=50 a/b=2 a%b=0
Compound Statement Operator It combines the assignment statement with arithmetic operator Syntax:Variable op= expression Variable: The variable to assign a value Op: Any arithmetic operator Expression:  It can be a constant, variable or arithmetic operation Example: N+=10 ~ N=N+10
Saqibmunawar
Switch Statement It is a conditional structure It is an alternative of “nested if” It is used when there are many choices are available and we need one to be executed
Syntax
Example
Nested Switch
C++,logical statements and assighnment statement

Mais conteúdo relacionado

Destaque

c++ programming Unit 3 variables,data types
c++ programming Unit 3 variables,data typesc++ programming Unit 3 variables,data types
c++ programming Unit 3 variables,data typesAAKASH KUMAR
 
Principles of programming languages. Detail notes
Principles of programming languages. Detail notesPrinciples of programming languages. Detail notes
Principles of programming languages. Detail notesVIKAS SINGH BHADOURIA
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Typesk v
 

Destaque (6)

c++ programming Unit 3 variables,data types
c++ programming Unit 3 variables,data typesc++ programming Unit 3 variables,data types
c++ programming Unit 3 variables,data types
 
Data types
Data typesData types
Data types
 
Data types
Data typesData types
Data types
 
Principles of programming languages. Detail notes
Principles of programming languages. Detail notesPrinciples of programming languages. Detail notes
Principles of programming languages. Detail notes
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
 
Data types
Data typesData types
Data types
 

Último

Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 

Último (20)

Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 

C++,logical statements and assighnment statement

  • 1.
  • 2.
  • 3. Switch statement Logical Statement Assignment Statement Computer programming C++
  • 4. Instructor Sir AamirJamshid
  • 5. Crew Members AzeemMumtaz SaqibMunawar Hafiz Ashfaq M.ZeeshanArshad
  • 6. Logical Statements AND operator It is used to evaluate two conditions . It produces true result if both conditions are true It produces false if any one condition is false Symbol: “&&”
  • 9. Output Enter the first number 1 Enter the second number 0 0
  • 10. OR operator It is used to evaluate two conditions It produces true if either condition is true It produces false result if both conditions are false Symbol: “| |”
  • 13. Output Enter the first number 1 Enter the second number 0 1
  • 14. Not Operator It is the reverses the result of condition It gives True if condition is false It gives false if condition is true Symbol: “!”
  • 15. Example ≡ File Edit Search Run Compile Debug Project Options Window Help ╔═[■]════════════════════════════ NONAME00.CPP ══════════════════════════1═[↑]═╗ ║#include<iostream.h> ▲ ║#include<conio.h> ■ ║void main() ▒ ║{ ▒ ║clrscr(); ▒ ║int a; ▒ ║cout<<"Enter the number"<<endl; ▒ ║cin>>a; ▒ ║if(a%2!=0) ▒ ║cout<<"the number is odd"; ▒ ║else ▒ ║cout<<"the number is even"; ▒ ║getch(); ▒ ║} ▼ ╚═☼════ 14:3 ═════◄■▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒►─┘ ┌────────────────────────────────── Message ─────────────────────────────2─────┐ │•Compiling NONAME00.CPP: │ │ Linking TCDEF.EXE: │ │ │ │ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ F1 Help Alt-F8 Next Msg Alt-F7 PrevMsg Alt-F9 Compile F9 Make F10 Menu
  • 16. Output Enter the number 8 The number is even
  • 18. Assignment Statement A statement that assigns a value to a variable is known as assignment statement. The assignment =is used in assignment statement to assign a value or computational result to a variable. The name of variable is written on the left side of assignment operator and the value is written on the right side. The value can be a constant ,variable ,expression or a function.
  • 19. Syntax Variable=Expression Examples A=100; C=a+b; X=c-d+10;
  • 20. LVALUE & RVALUE An L value is an operand that can be written on the left side of assignment operator=it must always be a single value. An rvalue is an operand that can be written on the right side of assignment statement=. All Lvaues can be used as Rvalues.
  • 21. Example ≡ File Edit Search Run Compile Debug Project Options Window Help ╔═[■]════════════════════════════ NONAME00.CPP ══════════════════════════1═[↑]═╗ ║#include<iostream.h> ▲ ║#include<conio.h> ■ ║void main() ▒ ║{clrscr(); ▒ ║inta,b; ▒ ║a=10; ▒ ║b=5; ▒ ║cout<<"a+b="<<a+b<<endl; ▒ ║cout<<"a-b="<<a-b<<endl; ▒ ║cout<<"a*b="<<a*b<<endl; ▒ ║cout<<"a/b="<<a/b<<endl; ▒ ║cout<<"a%b="<<a%b<<endl; ▒ ║getch(); ▒ ║} ▼ ╚═☼════ 14:2 ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒►─┘ ┌────────────────────────────────── Message ─────────────────────────────2─────┐ │•Compiling NONAME00.CPP: │ │ Linking NONAME00.EXE: │ │ │ │ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ F1 Help Alt-F8 Next Msg Alt-F7 PrevMsg Alt-F9 Compile F9 Make F10 Menu
  • 24. Output a+b=15 a-b=5 a*b=50 a/b=2 a%b=0
  • 25. Compound Statement Operator It combines the assignment statement with arithmetic operator Syntax:Variable op= expression Variable: The variable to assign a value Op: Any arithmetic operator Expression: It can be a constant, variable or arithmetic operation Example: N+=10 ~ N=N+10
  • 27. Switch Statement It is a conditional structure It is an alternative of “nested if” It is used when there are many choices are available and we need one to be executed