compter pogramming and utilization
TRANSCRIPT
![Page 1: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/1.jpg)
COMPTER POGRAMMING AND UTILIZATION
CONTROL STRUCTURES IN ‘C’
GUIDED BY: Prof. Parin Patel
![Page 2: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/2.jpg)
GROUP MEMBERSNAME
RAJPUT ROHANSHARMA MAULIKSINGH DEVANSHSINGH UDDESHYA
![Page 3: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/3.jpg)
CONTENTS Introduction If Statement Simple if Statement If….else Statement Nested if Statement The Else If Ladder The Switch Statement The ?:operator The GOTO Statement The while Statement The do Statement The for Statement
![Page 4: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/4.jpg)
INTRODUCTION DECISION MAKING In bank, if we want to withdraw money, there
should be enough bank balance. So certain actions can take place if specific conditions are satisfied. This is called decision making.
C language supports following statements for decision making capability.
1. If statement2. Switch statement3. Conditional operator statement4. Goto statement
![Page 5: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/5.jpg)
1.IF STATEMENT The if statement is a powerful decision
making statement and is used to control the flow of execution of statements.
It is basically a two way decision statement and is used in conjuction with an expression.
General form if(expression) Statement(s);
![Page 6: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/6.jpg)
FLOW CHART OF IF CONTROL
![Page 7: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/7.jpg)
EXAMPLE OF IF CONTROL
![Page 8: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/8.jpg)
2.SIMPLE IF STATEMENT General form if (test expression) { statement-block; } statement x;
![Page 9: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/9.jpg)
FLOW CHART OF SIMPLE IF CONTROL
![Page 10: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/10.jpg)
EXAMPLE OF SIMPLE IF CONTROL
![Page 11: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/11.jpg)
3.IF….ELSE STATEMENT The if….else statement is an extension of the simple if
statement. General form if (test expression) { true-block statement(s) } else { false-block statement(s) } statement x
![Page 12: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/12.jpg)
FLOW CHART OF IF….ELSE CONTROL
![Page 13: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/13.jpg)
EXAMPLE OF IF….ELSE CONTROL
![Page 14: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/14.jpg)
4.NESTED IF STATEMENT General form if (test condition-1) { if (test-condition-2); { statement-1; } else { statement-2; } } else { statement-3; } statement-x;
![Page 15: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/15.jpg)
FLOW CHART OF NESTED IF STATEMENT
![Page 16: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/16.jpg)
EXAMPLE OF NESTED IF STATEMENT
![Page 17: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/17.jpg)
5.THE ELSE IF LADDER General form if (condition 1) statement-1; else if (condition 2) statement-2; else if (condition 3) statement-3; else if (condition n) statement-n; else default statement; statement-x;
![Page 18: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/18.jpg)
FLOW CHART OF ELSE….IF LADDER
![Page 19: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/19.jpg)
EXAMPLE OF ELSE….IF LADDER
![Page 20: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/20.jpg)
6.THE SWITCH STATEMENT General form switch (expression) { case value-1: block-1 break; case value-2: block-2 breal; …………….. …………….. default: default-block break; } statement-x;
![Page 21: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/21.jpg)
SELECTION PROCESS OF SWITCH STATEMENT
![Page 22: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/22.jpg)
EXAMPLE OF SWITCH STATEMENT
![Page 23: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/23.jpg)
7.THE?: OPERATOR The ?: operator is used to make two way
decision. General form conditional expression?
expression1:expression2
![Page 24: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/24.jpg)
EXAMPLE OF ?: OPERATOR
![Page 25: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/25.jpg)
8.THE GOTO STATEMENT In “C” language goto statement is used to jump unconditionally from one point to another in
the same program. The goto statement requires a label. General form (forward jump) goto skip; …………….. …………….. …………….. skip: statement;
(backward jump) skip: statement; …………….. …………….. …………….. goto skip;
![Page 26: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/26.jpg)
EXAMPLE OF GOTO STATEMENT
![Page 27: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/27.jpg)
9.THE WHILE STATEMENT The simplest of the looping structures in
C is the while statement. The while is an entry-controlled loop statement.
General form while (test condition) { body of the loop }
![Page 28: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/28.jpg)
EXAMPLE OF WHILE STATEMENT
![Page 29: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/29.jpg)
10.THE DO STATEMENT In certain situations, it is necessary to execute
the body of the loop at least once and then condition should be tested. In that situation do statement is used.
General form do { statement block; } while(condition);
![Page 30: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/30.jpg)
EXAMPLE OF DO STATEMENT
![Page 31: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/31.jpg)
11.THE FOR STATEMENT The for statement for loop is used to
repeatedly execute statement or block of statements fixed numbers of times.
General form for (initialization;test-
condition;increment) { body of the loop }
![Page 32: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/32.jpg)
EXAMPLE OF FOR STATEMENT
![Page 33: Compter pogramming and utilization](https://reader034.vdocuments.us/reader034/viewer/2022051501/58a5777f1a28ab36768b59d5/html5/thumbnails/33.jpg)