Lecture14 Conditional Execution 2

Lecture14 Conditional Execution 2 - Lecture14: Course:...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
FAST, National University of Computer and Emerging Sciences, Islamabad 1 Lecture 14:  Conditional Execution-II Course: Programming For Engineers-1 Asma Ahmad
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Contents If selection statement If else selection statement 2
Background image of page 2
Need In every day life, we often making decisions. For example, the statement ‘if the shop is open, bring one kg of sugar while returning home from college’, involves this phenomenon. Thus we are making a decision on the condition that the shop is open.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
More Examples The college gives admission to a student if he has the required percentage in his previous examination and/or in the entry test. Similarly administration of a basketball team of the college decides that the students having height more than six feet can be members of the team.
Background image of page 4
If statement If-else statement Nested If-else statement Switch Statement Conditional Operator
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
1. if statement Every programming language provides a structure for decision making. 'C' also provides this structure. The statement used for decisions in 'C' language is known as the ' if statement'.
Background image of page 6
7 The  if  Selection Statement Selection structure: Used to choose among alternative courses of action Pseudocode: If student’s grade is greater than or equal to 60 Print “Passed” If condition true Print statement executed and program goes on to next statement If false , print statement is ignored and the program goes onto the next statement Indenting makes programs easier to read C ignores whitespace characters
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 The  if  Selection Statement Pseudocode statement in C: if ( grade >= 60 )     printf( "Passed\n" );  C code corresponds closely to the pseudocode if ( grade >= 60 )  {    printf( "Passed\n" );  } true false grade >= 60 print “Passed”
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/21/2011 for the course EE 1 taught by Professor Shahidanwar during the Spring '10 term at NUCES.

Page1 / 32

Lecture14 Conditional Execution 2 - Lecture14: Course:...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online