control statement in c programming vijay

7
Multimedia Multimedia Help you to learn anything in a playful manner…………. Slide Created by :-Vijay Kumar Sharma Enrolment No :- 073575052 Course & Batch :- BCA 4/2 Subject Code :- CS-66

Upload: vijaysharma24x7

Post on 17-Nov-2014

105 views

Category:

Documents


1 download

DESCRIPTION

Control Statement in C Programming Vijay

TRANSCRIPT

Page 1: Control Statement in C Programming Vijay

MultimediaMultimediaHelp you to learn anything in a playful manner………….

Slide Created by :-Vijay Kumar Sharma

Enrolment No :- 073575052

Course & Batch :- BCA 4/2

Subject Code :- CS-66

Page 2: Control Statement in C Programming Vijay

Control Statement Control Statement in C Programmingin C Programming

C programming language is popular C programming language is popular

for its capability of decision making.for its capability of decision making.

Now we are going to learn about Now we are going to learn about

“Control State in C Programming”“Control State in C Programming”

Page 3: Control Statement in C Programming Vijay

Control Statement in C Control Statement in C ProgrammingProgramming

If StatementIf Statement

Multiple If StatementsMultiple If Statements

If-else StatementIf-else Statement

Nested if-elseNested if-else

Page 4: Control Statement in C Programming Vijay

The If The If StatementStatement

Like most programming languages, C Like most programming languages, C uses the keyword if to implement the uses the keyword if to implement the decision control instruction. The decision control instruction. The general form of if state look like thisgeneral form of if state look like this

If(this condition is true)If(this condition is true)

execute this statement;execute this statement;

Page 5: Control Statement in C Programming Vijay

Multiple Statement With Multiple Statement With in Ifin If

It may happen that in a program we It may happen that in a program we want more than one statement to be want more than one statement to be executed if the expression following if is executed if the expression following if is satisfied. Then statement will be like satisfied. Then statement will be like thisthis

If(condition)If(condition)

{{

Statement;Statement;

Statement;Statement;

Statement;Statement;

}}

Page 6: Control Statement in C Programming Vijay

If-else If-else StatementStatement

We execute one group of statement of if the expression evaluates to true and another group of statement if the expression evaluates to false? Of course! This is what is the purpose of the else statement that is demonstrated in the following syntax

If(condition)Do this;

Else Do this;

Page 7: Control Statement in C Programming Vijay

Nested if-elseNested if-elseIt is perfectly all right if we write an entire if-It is perfectly all right if we write an entire if-else construct within either the body of the if else construct within either the body of the if statement or the body of an else statement. statement or the body of an else statement. This is called “Nesting” syntax is belowThis is called “Nesting” syntax is below

If(condition)If(condition)Do this;Do this;

ElseElse{ if(condition){ if(condition)Do this;Do this;

ElseElseDo thisDo this

}}