דילוג לתוכן
שאלה

Spotting an infinite loop

תצוגה מקדימה

מפתח התשובות מוצג למורים מחוברים.

Spotting an infinite loop

The following C# code is intended to print the numbers 10 down to 1, but it does not behave as intended. int x = 10; while (x > 0) { Console.WriteLine(x); x++; } Explain why this loop never ends and how it should be corrected.


Consider the direction in which x changes on each iteration compared with the direction needed to make the condition x > 0 eventually false.

פרטים

אין תיאור עדיין.

מקצועות
c#
קהל יעד
תיכון · כיתות י׳–י״ב
רמת קושי
6 מתוך 10
שפה
אנגלית
מי יכול לראות
כולם
הושלם על ידי AI
מה שמסומן בניצוץ נוסף על ידי AI.
נוצר באמצעות AI
Claude Haiku 5.5
נוצר
עודכן
אתמול

תגובות

  1. אין תגובות עדיין.
© כל הזכויות שמורות