Font size
Worksheetsloop while/do while
Total questions: 10
Worksheet time: 9mins
Which is the right syntax for the while loop?
WHILE bacon <= 5 { cout << "text"; }
while bacon <= 5 cout << "text";
while (bacon <= 5) { cout << "text"; }
Fill in the blanks.
(a)
เติมส่วนของโปรแกรมในช่องว่าง เพื่อเพิ่มค่าให้ตัวแปร bacon ครั้งละ 2 แล้วแสดงผลออกมาเรื่อยๆ
(a)
เติมส่วนของคำสั่ง เพื่อรับค่าจำนวนเต็ม 5 จำนวน
และหาผลรวมของจำนวนเหล่านั้น
โดยเก็บผลรวมไว้ในตัวแปร total
(a)
loop do...while ข้อใดถูกต้อง
do { } while (test);
doo while(test)
DO while test;
เติมส่วนของโปรแกรม เพื่อแสดงค่าของตัวแปร x 10 ครั้ง
(a)
How is a "do... while" loop different from a "while" loop?
while loop runs the code before testing the condition
do...while loop runs your code at least one time
do...while loop tests the condition before running the code
เติมส่วนของโปรแกรม เพื่อพิมพ์ข้อความ
"this is a loop" จำนวน 15 ครั้ง
(a)
Print i as long as i is less than 6.
(a)
Use the do/while loop to print i as long as i is less than 6.
(a)
