Presentation is loading. Please wait.

Presentation is loading. Please wait.

Statements

Similar presentations


Presentation on theme: "Statements"— Presentation transcript:

1

2 http://indiannova.in

3 Statements http://indiannova.in

4

5 Statement 1 Statement 2 Statement 3 http://indiannova.in

6 Respective statements If condition is false If condition is false Condition ? Respective statements If condition is true If condition is true http://indiannova.in

7 Condition ? Condition ? Statement 1 Statement 2 The exit condition false The loop body true http://indiannova.in

8

9 ‘if’ is called single selection structure because it select or ignore a single action. Syntax(general form):- if(condition) { c++ expression or statement ; } http://indiannova.in

10

11 A nested if is an if that has another if in its if’s body or in its else’s body. Syntax :- If(condition ) { c++ expression ; } if(condition ) { c++ expression ; } else { C++ expression ; } else { C++ expression ; } If(condition ) { c++ expression ; } if(condition ) { c++ expression ; } else { C++ expression ; } else { C++ expression ; } http://indiannova.in

12

13 Void main() { int age; Cout<<”Enter the age”; Cin>>age; If (age>=60) { Cout<<”Eligible”; }.else { Cout<<“Not”; }. getch (); } Examples of Selection Statement #include Void main() { int grade; Cout<<”Enter the grade”; Cin>>grade; If (grade>=60) { Cout<<”pass”; }. getch () } #include http://indiannova.in

14 Void main() { float a,b,Result; Char ch; Cout<<”Enter the number 1:”; Cout<<”Enter the number 2:”; Cin>>a>>b; Cin>>ch;.. if (ch==‘-’) Result=a-b;.else if (ch==‘+’) Result=a+b;.. else { Cout<<“Wrong entry”; } Cout<<Result;. getch (); } #include Void main() { int grade; Cout<<”Enter the grade in marks:”; Cin>>grade; switch (grade) { Case 90 :cout<<“A”; break; Case 80:cout<<“A”; break; Case 70 :cout<<“A”; break; Case 50 :cout<<“A”; break; Case 40 :cout<<“A”; break; default; } Cout<< “Wrong Entry”;. getch (); } #include Ex. Of Nested if Ex. Of Switch http://indiannova.in

15 The iteration statement allows a set of instruction to be perform repeatedly until a certain condition is felled. It is also known as Loop’s. Loops are of four types that is: http://indiannova.in

16

17

18

19

20 Examples of For and Nested Loop Void main() { int i;.. for (i =10;i<=10;i++) { Cout<<“\n”<<i; }. getch (); } #include Void main() { int i,j;.. for (i =1;i<5;i++) Cout<<“\n”; for (j=1;j<i; j++) Cout<<“*”;. getch (); } #include http://indiannova.in

21 Void main() { int i=1;.. while (i<=10) { cout<<i; } i++;. getch (); } #include Void main() { int i=1; do { cout<<i; } i++; while(i<=10). getch (); } #include Example of while and do-while loop http://indiannova.in

22

23

24

25 HTTP://INDIANNOVA.IN

26 http://indiannova.in

27


Download ppt "Statements"

Similar presentations


Ads by Google