मराठी

Select the infinite loop: (a) for(int i=1;i<=10;i++) (b) for(int i=2; i!=0 ;i-=3) (c) for(int i=5 ;i<=5;i++) (d) for(int i =1;i>=1; i - -) - Computer Applications

Advertisements
Advertisements

प्रश्न

Select the infinite loop:

पर्याय

  • for(int i=1;i<=10;i++)

  • for(int i=2; i!=0 ;i-=3)

  • for(int i=5 ;i<=5;i++)

  • for(int i =1;i>=1; i - -)

MCQ
रिकाम्या जागा भरा
Advertisements

उत्तर

for(int i=2; i!=0 ;i-=3)

Explanation:

  • The loop starts with the initial value i = 2. In each iteration, the value of i is decreased by 3 (i -= 3). The loop condition is i != 0.
  • As the value of i changes as 2, −1, −4, −7, …, it will never become 0. Therefore, the condition i != 0 always remains true, and the loop never terminates, making it an infinite loop.
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2024-2025 (March) Official Board
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×