Relational Operators, Decision - Introduction to Programming - Lecture Slides, Slides of Computer Programming

Relational Operators, Decision, Flow Chart Symbols, Flow Chart for if statement, Logical Operators, Unary Not operator, Nested if, Variables and Data types are the key points of this lecture.

Typology: Slides

2011/2012

Uploaded on 11/06/2012

somo
somo 🇮🇳

4.8

(4)

70 documents

1 / 28

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Introduction to Programming
Lecture 5
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c

Partial preview of the text

Download Relational Operators, Decision - Introduction to Programming - Lecture Slides and more Slides Computer Programming in PDF only on Docsity!

Introduction to Programming

Lecture 5

In the Previous Lecture

 Basic structure of C program  Variables and Data types  Operators  ‘cout’ and ‘cin’ for output and input  Braces

If Statement

If condition is true

statements

If Ali’s height is greater then 6 feet

Then

Ali can become a member of the Basket Ball team

If Statement in C

If (condition)

statement ;

If statement in C

if (age1 > age2)

cout<<“Student 1 is older

than student 2” ;

Relational Operators

< less than

<= less than or equal to

== equal to

= greater than or equal to

greater than

!= not equal to

Example

#include <iostream.h> main ( ) { int AmirAge, AmaraAge; AmirAge = 0; AmaraAge = 0; cout<<“Please enter Amir’s age”; cin >> AmirAge; cout<<“Please enter Amara’s age”; cin >> AmaraAge; if AmirAge > AmaraAge) { cout << “\n”<< “Amir’s age is greater then Amara’s age” ; } } Docsity.com

Flow Chart Symbols

Start or stop

Process

Continuation mark

Decision

Flow line

Example

If the student age is greater than 18 or his height is greater than five feet then put him on the foot balll team

Else

Put him on the chess team

Logical Operators

AND &&

OR ||

if-else

if (condition) { statement ;

} else { statement ;

} Docsity.com

if-else

Condition Process 1

IF Then

Entry point for IF-Else block

Exit point for IF block

Process 2

Else

Note indentation from left to right Docsity.com

Example

Code

if AmirAge > AmaraAge) { cout<< “Amir is older than Amara” ; } else { cout<<“Amir is younger than Amara” ; } Docsity.com

Make a small flow chart of this

program and see the one to one

correspondence of the chart

and the code