Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
17 views3 pages

PSPC Unit II A Decision Control Structure

The document outlines control structures in C programming, focusing on decision control structures such as if, if-else, and switch-case statements. It also covers loop structures including while, for, and do-while loops, as well as the use of break and continue statements. This material is intended for B Tech/B Tech (Hons.) CSE students in their first semester.

Uploaded by

gdrivee515
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

PSPC Unit II A Decision Control Structure

The document outlines control structures in C programming, focusing on decision control structures such as if, if-else, and switch-case statements. It also covers loop structures including while, for, and do-while loops, as well as the use of break and continue statements. This material is intended for B Tech/B Tech (Hons.) CSE students in their first semester.

Uploaded by

gdrivee515
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

10/12/2023

Dr. Dileep Kumar Singh


Head, JLU-SOET
[email protected]

Problem Solving and Program


Design using C

Dr. Dileep Kumar Singh 1

Problem Solving and Program Design using C

UNIT –II

B Tech/B Tech (Hons.) CSE – 1st Sem.

Decision Control Structure

Dr. Dileep Kumar Singh 2

Control Structures - if…else

• if Statements if (Condition) {
statements;
}

• if…else Statement if (Condition) {


statements; //true-case
}
• if…else if…else Statement
else {
statements; //false-case
• Nested if…else?? }

Dr. Dileep Kumar Singh 3

Dr. Dileep Kumar Singh 1


10/12/2023

Control Structures – switch…case

• switch…case Statements
switch (n)
{
case 1: // will execute if n = 1;
break;
case 2: // will execute if n = 2;
break;
default: // will execute if n doesn't match with any cases
}

Dr. Dileep Kumar Singh 4

Control Structures - Loops

• while loop

true
condition statement

false

Dr. Dileep Kumar Singh 5

Control Structures - Loops

• for loop

Initialize variable

Condition
true statement
Test the variable
Increment/Decrement
variable

false

Dr. Dileep Kumar Singh 6

Dr. Dileep Kumar Singh 2


10/12/2023

Control Structures - Loops

• do…while loop

do {
statement
statement
} while ( condition );
true
condition

false
• Nested Loops??

Dr. Dileep Kumar Singh 7

Control Structures - break & continue

• Break
Ex:
– Causes immediate exit from int next = 0;
a while, for, do/while while (true){
or switch statements Scanf(“%d”,&next);
if (next < 0)
• Continue
break;
– Skips the remaining if (next % 2) //odd number, don’t print
statements in the body of a continue;
while, for or do/while printf(“%d\n”,next);
structure and proceeds with }
the next iteration of the printf( “Out of the Loop!”);
loop

Dr. Dileep Kumar Singh 8

Thanks

Dr. Dileep Kumar Singh 9

Dr. Dileep Kumar Singh 3

You might also like