C++,logical statements and assighnment statement

31

description

i had made it with hard work so i offer it you because i can feel your feelings text tym i shall upload mora beautiful and comprehensive ppts.

Transcript of C++,logical statements and assighnment statement

Page 1: C++,logical statements and assighnment statement
Page 2: C++,logical statements and assighnment statement
Page 3: C++,logical statements and assighnment statement

Switch statement Logical Statement

Assignment Statement

Computer programmingC++

Page 4: C++,logical statements and assighnment statement

Instructor

Sir Aamir Jamshid

Page 5: C++,logical statements and assighnment statement

Crew Members

Azeem Mumtaz Saqib Munawar Hafiz Ashfaq M.Zeeshan Arshad

Page 6: C++,logical statements and assighnment statement

Logical Statements

AND operatorIt is used to evaluate two conditions .It produces true result if both conditions are

trueIt produces false if any one condition is

falseSymbol: “&&”

Page 7: C++,logical statements and assighnment statement

Working

Page 8: C++,logical statements and assighnment statement

Example

Page 9: C++,logical statements and assighnment statement

Output

Enter the first number1Enter the second number00

Page 10: C++,logical statements and assighnment statement

OR operatorIt is used to evaluate two conditionsIt produces true if either condition is

true It produces false result if both

conditions are false

Symbol: “| |”

Page 11: C++,logical statements and assighnment statement

Working

Page 12: C++,logical statements and assighnment statement

Example

Page 13: C++,logical statements and assighnment statement

Output

Enter the first number1Enter the second number01

Page 14: C++,logical statements and assighnment statement

Not Operator

It is the reverses the result of conditionIt gives True if condition is falseIt gives false if condition is trueSymbol: “!”

Page 15: C++,logical statements and assighnment statement

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 Prev Msg Alt-F9 Compile F9 Make F10 Menu

Page 16: C++,logical statements and assighnment statement

Output

Enter the number8The number is even

Page 17: C++,logical statements and assighnment statement

Hafiz Ashfaq

Page 18: C++,logical statements and assighnment statement

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.

Page 19: C++,logical statements and assighnment statement

Syntax

Variable=Expression Examples A=100; C=a+b; X=c-d+10;

Page 20: C++,logical statements and assighnment statement

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.

Page 21: C++,logical statements and assighnment statement

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,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 Prev Msg Alt-F9 Compile F9 Make F10 Menu

Page 22: C++,logical statements and assighnment statement

M.Zeeshan Arshad

Page 23: C++,logical statements and assighnment statement

Example

Page 24: C++,logical statements and assighnment statement

Output

a+b=15

a-b=5

a*b=50

a/b=2

a%b=0

Page 25: C++,logical statements and assighnment statement

Compound Statement Operator

It combines the assignment statement with arithmetic operator

Syntax: Variable op= expressionVariable: The variable to assign a valueOp: Any arithmetic operatorExpression: It can be a constant, variable

or arithmetic operationExample: N+=10 ~ N=N+10

Page 26: C++,logical statements and assighnment statement

SAQIB MUNAWAR

Page 27: C++,logical statements and assighnment statement

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

Page 28: C++,logical statements and assighnment statement

Syntax

Page 29: C++,logical statements and assighnment statement

Example

Page 30: C++,logical statements and assighnment statement

Nested Switch

Page 31: C++,logical statements and assighnment statement