Download presentation
Presentation is loading. Please wait.
Published byClaire Cox Modified over 9 years ago
1
Understanding Loops Using C Language Week 15 Mr.Omer Salih
2
Loop For loop While loop Do-While loop Break and Continue Mr.Omer Salih
3
For loop Syntax: for ( variable initialization; condition; variable update ) { Code to execute while the condition is true } Mr.Omer Salih
4
Write a c program for printing 0-9 using for loop #include int main() { int x; for ( x = 0; x < 10; x++ ) { printf( "%d\n", x ); } getchar(); } Mr.Omer Salih
5
While loop Syntax: While( ) { } Mr.Omer Salih
6
Do-While loop Syntax: do { } while ( condition ); Mr.Omer Salih
7
C programs Q) Write a c program for addition of two numbers. #include int main() { int a, b, c; printf("Enter two numbers to add\n"); scanf("%d%d",&a,&b); c = a + b; printf("Sum of entered numbers = %d\n",c); return 0; } Mr.Omer Salih
8
C program to check odd or even using modulus operator #include main() { int n; printf("Enter an integer\n"); scanf("%d",&n); if ( n%2 == 0 ) printf("Even\n"); else printf("Odd\n"); return 0; } Mr.Omer Salih
9
Session 15 End Mr.Omer Salih
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.