Lecture2 - Loop Example
Lecture2 - Loop Example
Lecture2 - Loop Example
continue
Switch
Switch
hi hello
Switch
Switch
65
hihello
The value of case 2,3 and default will be printed
Compilation error, the value of switch should be integer
bihellohiend
biend
Nothing will be printed as there is no case
Ordering of case does not matter
For input 1 and 2 hello will be printed
DECISION MAKING AND LOOPING
The test-condition is evaluated and if the condition is true, then the body of the
loop is executed.
After execution of the body, the test-condition is once again evaluated and if it
is true, the body is executed once again.
This process of repeated execution of the body continues until the test-condition
finally becomes false and the control is transferred out of the loop.
Example of WHILE Loop
sum = 0;
n = 1;
while(n <= 10)
{
sum = sum + n;
n = n + 1;
}
printf(“sum = %d \n”,sum);
-----------
-----------
THE DO STATEMENT
Cont..
1. http://www.computer-books.us/c_0008.php
2. http://www.computer-books.us/c_0009
3. http://www.computer-books.us/c_2.php
4. www.tutorialspoint.com/cprogramming/cprogramming_pdf.
5. Programming in C by yashwant kanitkar
6. ANSI C by E.balagurusamy- TMG publication
7. Computer programming and Utilization by sanjay shah Mahajan Publication
8. www.cprogramming.com/books.html
9. Rushdi Shams