C Programming Lecture no 5 Control Statements Department
- Slides: 32
C Programming Lecture no. 5 Control Statements
คำสงในการควบคมโปรแก รม Department of Computer Science 2 310322 C Programming
������� if. . . else ������ if / else ������ if <condition> statement 1; else statement 2; condition = ���������� statement = ���������� if (score>80) printf (“Excellent”); 3 else printf (“Good”); Department of Computer Science 310322 C Programming
Flow Chart ������� Yes Condition Statement 2 Statement 1 Department of Computer Science No 4 310322 C Programming
������� if. . . else if ������ if / else ������ if <condition 1> statement 1; else if <condition 2> statement 2; else statement 3; ���� if (score>80) printf (“Very Good”); else if (score>70) printf (“Good”); else printf (“Standard”); Department of Computer Science 5 310322 C Programming
������� Switch ������ switch(variable) { case constant 1: statement 1; break; case constant 2: statement 2; break; } variable = ������ constant = ������ int ���� char ���������� Department of Computer Science 6 310322 C Programming
Flow Chart ��������� No Condition 1 Yes Statement 1 Condition 2 No Yes Condition 3 Statement 2 Yes Statement 3 Department of Computer Science No 7 Statement 4 310322 C Programming
��������������������� if <value 1 operand value 2> statement 1; else if <value 3 operand value 4 logical operand value 5 operand value 6> statement 2; else statement 3; value = ���������� operand = ����������� logical operand = 8 Department of Computer Science 310322 C Programming
�������������� if (score > 70) printf (“Grade B”); else ((score<=70) && (score >=60)) printf (“Grade C”); else printf (“Grade D”); Department of Computer Science 10 310322 C Programming
คำสง loop หรอ คำสงวนซำ Department of Computer Science 11 310322 C Programming
������ for ( initial; condition; increment (decrement) ) statement; initial = ��������� condition = ��������� increment (decrement) = ����������� statement = ��������� Department of Computer Science 13 310322 C Programming
������ for (i=1; i<10; i++) printf (“%d”, i); ���� Department of Computer Science for (i=10; i>=1; i--) printf (“%d”, i); 14 310322 C Programming
Flow Chart ������� for Initial Condition Yes Statement No Increment (Decrement) Department of Computer Science 15 310322 C Programming
2. คำสง รปแบบ ล ป while (นพจนเงอนไข ) { คำสงทวน ลป ; ………… compound statements. ………… { Department of Computer Science 16 310322 C Programming
������ while (condition) statement; condition = ����������� statement = ����������� Department of Computer Science 17 310322 C Programming
������ while ���� i=1; while ( i<10 ) { printf (“%d”, i); i++; } Department of Computer Science 18 310322 C Programming
Flow Chart ������� while Initial Condition Yes Statement No Increment (Decrement) Department of Computer Science 19 310322 C Programming
3. คำสงวนรอบแบบทตรวจสอบเงอนไขทหลง : do. . . while รปแบบ do statement; while (นพจนเงอนไข เชน ); num = 2; do { num++; printf(“Now no is %dn”, num); } while (num == 10) Department of Computer Science 20 310322 C Programming
������ do. . . while ������ do / while ������ do { statement; } while (condition); condition = ���������� statement = 21 ���������� Department of Computer Science 310322 C Programming
������ do. . . while ���� i=1; do { printf(“%d”, i); i++; } while ( i<10 ); Department of Computer Science 22 310322 C Programming
Flow Chart ������� do. . . while Initial Statement Increment (Decrement) Condition Yes Department of Computer Science 23 No 310322 C Programming
คำสงควบคมอน ๆ break, continue, goto และ labels Department of Computer Science 24 310322 C Programming
������ break; ���� for (i=1; i<10; i++) { if (i == 5 ) break; printf (“%d”, i); } Department of Computer Science 26 310322 C Programming
������ continue; ���� for (i=1; i<10; i++) { if (i = = 5 ) continue; printf (“%d”, i); } Department of Computer Science 27 310322 C Programming
������ goto label; statement 1; label : statement 2; label = ������� statement = ��������� Department of Computer Science 29 310322 C Programming
������ goto ���� if (num == 5 ) goto end_work; printf (“num not equa 5”); end_work: printf (“num equa 5”); Department of Computer Science 30 310322 C Programming
ตวอยางโปรแกรมทใชค ำสง goto #include<stdio. h < main() }int sum, n ; for(n=1; n<10; n++) if (n==5) goto part 1; else printf(“%dn”, n); part 1 : printf(“Interrupt with no. 5n”); } Department of Computer Science 31 310322 C Programming
END
- 01:640:244 lecture notes - lecture 15: plat, idah, farad
- C data types with examples
- Perbedaan linear programming dan integer programming
- Greedy algorithm vs dynamic programming
- Runtime programming
- Linear vs integer programming
- Perbedaan linear programming dan integer programming
- Struktur kontrol java
- Conditional control
- Control statements in java
- Leather quality control
- C++ control structures
- Translational research institute on pain in later life
- Product control and process control
- Reynolds transport theorem
- Stock control e flow control
- Control volume vs control surface
- Positive control vs negative control
- What is a negative control
- Hdlc adalah
- Control de flujo parada y espera
- Negative control vs positive control examples
- Flow and error control
- Scalar control vs vector control
- Komponen ltspice
- Project procurement management lecture notes
- Lecture about sport
- Lecture on healthy lifestyle
- Existentialism vs nihilism
- Life lecture meaning
- Randy pausch last lecture summary
- Tensorflow lecture
- Theology proper lecture notes