Your SlideShare is downloading. ×
0
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Control structures in c
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Control structures in c

143

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
143
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Arun .R. Menon arunrmenon555@gmail.com www.facebook.com/arunrmenon twitter.com/iamarunmenon in.linkedin.com/in/mearunmenon +919846629020 Control Structures in C
  • 2. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • 3. Control Structures • System working • Why control structures ? • What is control Structures?
  • 4. Styles of Control Structures in C • Branching • Looping
  • 5. Branching • What is Branching ? • if statements • ? : Operator • switch statement
  • 6. if statements • If • if (expression) statement; or • if (expression) { Block of statements; }
  • 7. • If ……..else if (expression) { Block of statements; } else { Block of statements; } • else if if (expression) { Block of statements; } else if(expression) { Block of statements; }
  • 8. #include <stdio.h> main() { int cows = 6; if (cows > 1) printf("We have cowsn"); if (cows > 10) printf("loads of them!n"); else printf("Executing else part...!n"); if (cows == 5 ) { printf("We have 5 cowsn"); } else if( (cows == 6 ) { printf("We have 6 cowsn"); } We have cows Executing else part...! We have 6 cows
  • 9. ? : Operator • Similar to if • ternary operator Eg #include <stdio.h> main() { int a , b; a = 10; printf( "Value of b is %dn", (a == 1) ? 20: 30 ); printf( "Value of b is %dn", (a == 10) ? 20: 30 ); } Value of b is 30 Value of b is 20
  • 10. switch statement #include <stdio.h> main() { int Grade = ‘ ’; switch( Grade ) { case 'A' : printf( "Excellentn" ); break; case 'B' : printf( "Goodn" ); break; case 'C' : printf( "OKn" ); break; case 'D' : printf( "Mmmmm....n" ); break; case 'F' : printf( "You must do better than thisn" ); break; default : printf( "What is your grade anyway?n" ); break; } } A Excellent B C D F def Good Ok Mmmm You must do .. What is your
  • 11. Looping • What is looping • for • while • dowhile
  • 12. for loop #include <stdio.h> main() { int i; for( i = 0; i <= j; i ++ ) { printf("Hello %dn", i ); if( i == 6 ) { break; } } } Hello 0 Hello 1 Hello 2 Hello 3 Hello 4 Hello 5 Hello 6
  • 13. while #include <stdio.h> main() { int i = 0; while ( i < 5 ) { if(i==4) continue; printf("Hello %dn", i ); i = i -1; } } Hello 0 Hello 1 Hello 2 Hello 5
  • 14. do while #include <stdio.h> main() { int i = 10; do{ printf("Hello %dn", i ); i = i -1; if( i == 6 ) { break; } } while ( i > 0 ); } Hello 10 Hello 9 Hello 8 Hello 7 Hello 6
  • 15. #include <stdio.h> main() { int i = 1; do{ printf("Hello %dn", i ); i = i -1; if( i == 6 ) { break; } } while ( i > 5 ); } Hello 1
  • 16. THANK YOU
  • 17. Want to learn more about programming or Looking to become a good programmer? Are you wasting time on searching so many contents online? Do you want to learn things quickly? Tired of spending huge amount of money to become a Software professional? Do an online course @ baabtra.com We put industry standards to practice. Our structured, activity based courses are so designed to make a quick, good software professional out of anybody who holds a passion for coding.
  • 18. Follow us @ twitter.com/baabtra Like us @ facebook.com/baabtra Subscribe to us @ youtube.com/baabtra Become a follower @ slideshare.net/BaabtraMentoringPartner Connect to us @ in.linkedin.com/in/baabtra Give a feedback @ massbaab.com/baabtra Thanks in advance www.baabtra.com | www.massbaab.com |www.baabte.com
  • 19. Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Cafit Square, Hilite Business Park, Near Pantheerankavu, Kozhikode Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com Contact Us

×