4. เลือกปฏิบัติ

The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

 
รหัสที่ 4-16  ส่วนของโปรแกรมหาค่ามากสุดของ a, b, และ c (ทำงานผิด)
  int max;
  if ((a>b) && (a>c)) max = a;      // a มากสุด 
  else if ((b>a) && (b>c)) max = b; // b มากสุด 
  else max = c;    // a และ b ไม่มากสุด, c ก็ต้องมากสุด 
©2009 S.Prasitjutrakul