Important Announcement
PubHTML5 Scheduled Server Maintenance on (GMT) Sunday, June 26th, 2:00 am - 8:00 am.
PubHTML5 site will be inoperative during the times indicated!

Home Explore การโปรแกรมคอมพิวเตอร์

การโปรแกรมคอมพิวเตอร์

Published by weerathum, 2018-04-10 10:08:07

Description: หน่วยที่ 15 คำสั่งเงื่อนไข if–else

Search

Read the Text Version

AR Book การโปรแกรมคอมพวิ เตอร(Computer Programming) หนว ยท่ี 15 คําส่งั เงอ่ื นไข if–else จดั ทําโดย นายนําพล วงศโ สภา

เน้อื หาสาระพอสงั เขปคาํ สัง่ เงอ่ื นไข if–else เปนคาํ สงั่ ตดั สินใจ เลือกทํางานในชดุ คาํ ส่งั ใดชดุ คาํ สั่งหน่ึง ซง่ึ พิจารณาจากเง่ือนไขทก่ี ําหนดเม่ือเงือ่ นไขท่กี าํ หนดเปน จริงใหท ํางานชดุ คาํ ส่ัง ifแตถ า เงอ่ื นไขเปน เทจ็ ใหท าํ งานชุดคาํ สั่งของ else

รปู แบบที่ 1 แผนภมู ิการทาํ งาน if (Condition) ConditTioruen Statement 2;Statement 1 ; else FalseStatement 2 ; Statement 1;

โปรแกรม แสดงการทาํ งานของคาํ สงั่ if–else 1 #include <stdio.h> 2 #include <conio.h> 3 int main ( ) 4{ 5 int A, B; 6 printf( \"Enter integer 1 : \" ); 7 scanf( \"%d\", &A ); 8 printf( \"Enter integer 2 : \" ); 9 scanf( \"%d\", &B );10 printf( \"\n\" );11 if (( A + B ) >= 50 )12 printf( \"Pass\" );

13 else14 printf( \"Fail\" );15 getch ( );16 return 0;17 }ผลลพั ธของโปรแกรม หนว ยท่ี 15 คําสง่ั เง่ือนไข if–else if (Condition) Statement 1 ; else Statement 2 ;


Like this book? You can publish your book online for free in a few minutes!
Create your own flipbook