วันศุกร์ที่ 20 กันยายน พ.ศ. 2556

=While=(Eazy)

Programming Exercise
Proposition =>Write a while clause that stops a posttest loop when the value in the quantity variable in less than the number 0.
Translated into Thailand =>  ให้เขียน while loop แล้วให้หยุดเมื่อค่า ในตัวแปลน้อยกว่า0

Solution=> 
int c=10;
while(c>=0){

 c--;

}





You can run code in http://processingjs.org/tools/processing-helper.html

อธิบายการทำงานของโปรแกรม => ทุกๆครั้งที่มีการวนลูป ค่าcจะลดลงทุกๆครั้งก่อนออกจากลูป
และจะจบการทำงานเมื่อเงื่อนไข c>=0 ไม่เป็นจริง


text book name :Programming and problem solving with Java – 2nd edition
Author : Nell Dale and Chip Weems
              ISBN 978-0-7637-3402-2

ไม่มีความคิดเห็น:

แสดงความคิดเห็น