Logo
최고의 농부
quiz thumbnail
แบบรอบ
มัธยมต้น 7
อื่น ๆ

Basic C++ Debugging Quiz M.1

ระบบบริหารจัดก

3
ผู้สร้างควิซต้นฉบับ-
ระบบบริหารจัดก

ควิซที่สร้างด้วยแผนที่พรีเมียม

20 ข้อ

อนุญาตให้คำตอบที่ไม่ถูกต้อง

แสดงคำตอบเสมอ

public quiz

# 1เลือกประเภท
#include <iostream> using namespace std; int main() { cout << "Hello World!" return 0; }
ลืมเครื่องหมายปีกกา {}
ลืม ; หลังคำสั่ง cout
ลืม #include
ไม่มี main()
# 2เลือกประเภท
#include <iostream> using namespace std; int main() { int a = "10"; cout << a; return 0; }
ตัวแปร a ไม่ได้ประกาศชนิดข้อมูล
ใช้ cout ไม่ถูก
กำหนดค่า "10" ซึ่งเป็นข้อความให้กับตัวแปรชนิด int
ลืม return
# 3เลือกประเภท
#include <iostream> using namespace std; int main() int x = 5; cout << x; return 0; }
ลืมเครื่องหมาย ;
ลืมปีกกาหลัง main()
ไม่มี using namespace std;
cout ไม่ควรอยู่ใน main
# 4เลือกประเภท
#include <iostream> using namespace std; int main() { float pi = 3.14 cout << pi; return 0; }
ประกาศตัวแปรผิด
ลืม ; หลัง pi = 3.14
float ใช้กับจำนวนเต็มเท่านั้น
cout ต้องใส่เครื่องหมาย ''
# 5เลือกประเภท
#include <iostream> using namespace std; int main() { int num; cin >> num; cout << "Number is " + num; return 0; }
ใช้ + ผิดในการรวมข้อความกับตัวแปร
ลืม cin
ต้องใช้ float แทน int
out ต้องอยู่ก่อน cin
# 6เลือกประเภท
#include <iostream> using namespace std; int main() { string name; cout << "Enter your name: "; cin << name; return 0; }
ใช้ cin ไม่ถูกต้อง
ลืม #include
string ใช้ไม่ได้
cout ไม่มี ;
# 7เลือกประเภท
#include <iostream> using namespace std; int main() { int a = 5, b = 2; cout << "a/b = " << a / b.0; return 0; }
a ไม่ได้ประกาศ
b.0 ไม่ถูกต้อง
<< ใช้ไม่ได้
ไม่มี return
# 8เลือกประเภท
#include <iostream> using namespace std; int main() { int a = 5; if a > 3 { cout << "True"; } return 0; }
ลืม ; หลัง if
ลืมวงเล็บ () ใน if
if ใช้กับ string เท่านั้น
cout อยู่ผิดที่
# 9เลือกประเภท
#include <iostream> using namespace std; int main() { for i = 0; i < 5; i++ { cout << i << " "; } return 0; }
ไม่มี for
วงเล็บใน for ผิด
ตัวแปร i ไม่ได้ประกาศ
ลืม ;
# 10เลือกประเภท
#include <iostream> using namespace std; int main() { int x = 10; while x > 0 { cout << x << " "; x--; } return 0; }
ลืม () ใน while
x-- ต้องใช้ ++
while ต้องอยู่ใน if
cout ใช้ผิด
# 11เลือกประเภท
#include <iostream> using namespace std; int main() { int a = 10; int b = 3; cout << "Result: " << a % b.0; return 0; }
ใช้ % กับทศนิยมไม่ได้
ต้องใช้ + แทน %
cout ต้องอยู่ก่อนการคำนวณ
a ไม่ได้ประกาศ
# 12เลือกประเภท
#include <iostream> using namespace std; int main() { int score; cout << "Enter score: "; cin >> score; if (score > 50) cout << "Pass"; else cout << "Fail" ret
ใช้ if ไม่ถูก
ลืม ; หลัง Fail
else ไม่ต้องใช้ใน C++
cin ใช้ไม่ได้
# 13เลือกประเภท
#include <iostream> using namespace std; int main() { int n = 3; switch (n) { case 1: cout << "One"; case 2: cout << "Two"; case 3:
ไม่มี break ทำให้พิมพ์หลายค่า
switch ใช้กับ float เท่านั้น
ลืม default
ต้องมี else if แทน case
# 14เลือกประเภท
#include <iostream> using namespace std; int main() { string name = "John; cout << name; return 0; }
cout ผิด
ขาด #include
ลืม " ปิด string
name ต้องใช้ตัวพิมพ์ใหญ่
# 15เลือกประเภท
#include <iostream> using namespace std; int main() { int a = 5 int b = 6; cout << a + b; return 0; }
ลืม ; หลัง int a = 5
a + b ไม่ได้
int ใช้ไม่ได้ใน main
cout ต้องใช้ , ไม่ใช่ +
# 16เลือกประเภท
#include <iostream> using namespace std; int main() { int x; cout << "Input number: "; cin >> x; cout << "Square is: " << x * x << endl }
ขาด ; ปิด endl
* ใช้ไม่ได้
ต้องใช้ pow()
x เป็น string ต้องแปลง
# 17เลือกประเภท
#include <iostream> using namespace std; int main() { cout << "Today is " << Monday; return 0; }
ลืมใส่ " ครอบคำว่า Monday
cout ใช้ไม่ได้
ไม่มี int main()
return ใช้ผิด
# 18เลือกประเภท
#include <iostream> using namespace std; int main() { bool isOk = "true"; if (isOk) cout << "OK"; return 0; }
ลืมใส่ {}
กำหนดค่า bool ผิด
ไม่มี cout
if ใช้ผิด
# 19เลือกประเภท
#include <iostream> using namespace std; int main() { int x = 10; int y = 3; double z = x / y; cout << z; return 0; }
ผลลัพธ์จะผิดเพราะหารแบบ int
ต้องใช้ float แทน int
ต้องใช้ +
ลืม #include
# 20เลือกประเภท
#include <iostream> using namespace std; int main() { for (int i = 0; i < 5; i++); cout << i << " "; return 0; }
ลืมปีกกา
int i = 0 ผิด
cout อยู่ใน loop
มี ; หลัง for ทำให้ loop ว่าง
การแชร์ Google Classroom

ควิซนี้สร้างด้วยแผนที่พรีเมียม ไม่สามารถเข้าถึงได้เนื่องจากแพลนหมดอายุ