🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

लूप के लिए दो वेरिएबल x और y को एक साथ कैसे चलाएं?

How to run two variables x and y in for loop simultaneously?

A
for (x = 0; x<m, x++), for (y = 0; y<m, y+=3) { }
B
for (x = 0, y = 0; x<m, y<m; x++, y+=3)
C
Both (A) and (B)
D
for (x = 0; x<m, x++) { }, for (y = 0; y<m, y+=3) { }
Explanation

The correct way to run two variables x and y in a single for loop simultaneously involves having both variables initialized, updated, and checked together in the loop's structure.

Explanation:

  • Option (A) and Option (D) are incorrect because they represent two separate for loops. Each loop runs independently, so they do not execute simultaneously in the same loop structure.

  • Option (B) is the correct one. It initializes both x and y together, sets their conditions (x < m and y < m), and updates both variables in each iteration (x++ and y+=3).

Correct Answer:

(B) for (x = 0, y = 0; x.

Correct Answer: B) for (x = 0, y = 0; x<m, y<m; x++, y+=3)

Latest Updates