wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

loop while/do while

Total questions: 10

Worksheet time: 9mins

Name
Class
Date
1.

Which is the right syntax for the while loop?

a)

WHILE bacon <= 5 { cout << "text"; }

b)

while bacon <= 5 cout << "text";

c)

while (bacon <= 5) { cout << "text"; }

2.

Fill in the blanks.

(a)  

3.

เติมส่วนของโปรแกรมในช่องว่าง เพื่อเพิ่มค่าให้ตัวแปร bacon ครั้งละ 2 แล้วแสดงผลออกมาเรื่อยๆ

(a)  

4.

เติมส่วนของคำสั่ง เพื่อรับค่าจำนวนเต็ม 5 จำนวน

และหาผลรวมของจำนวนเหล่านั้น

โดยเก็บผลรวมไว้ในตัวแปร total

(a)  

5.

loop do...while ข้อใดถูกต้อง

a)

do { } while (test);

b)

doo while(test)

c)

DO while test;

6.

เติมส่วนของโปรแกรม เพื่อแสดงค่าของตัวแปร x 10 ครั้ง

(a)  

7.

How is a "do... while" loop different from a "while" loop?

a)

while loop runs the code before testing the condition

b)

do...while loop runs your code at least one time

c)

do...while loop tests the condition before running the code

8.

เติมส่วนของโปรแกรม เพื่อพิมพ์ข้อความ

"this is a loop" จำนวน 15 ครั้ง

(a)  

9.

Print i as long as i is less than 6.

(a)  

10.

Use the do/while loop to print i as long as i is less than 6.

(a)