Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  How many times is the comparison i > = n ... Start Learning for Free
How many times is the comparison i > = n performed in the following program?
int i=85, n=5;
main() {
while (i >= n) {        
i=i-1;        
n=n+1;
}
}
  • a)
    40
  • b)
    41
  • c)
    42
  • d)
    43
Correct answer is option 'C'. Can you explain this answer?
Verified Answer
How many times is the comparison i > = n performed in the followin...
It will start comparison from (85, 5), (84, 6), (83, 7) .............. (45, 45), (44, 46)
Hence total number of comparison will be (85-44) + 1 = 41 + 1 = 42
View all questions of this test
Most Upvoted Answer
How many times is the comparison i > = n performed in the followin...
Explanation:

In the given program, the comparison i = n is performed multiple times within the while loop. Let's break down the program step by step to determine the number of times the comparison is performed.

1. Initialize variables:

i = 85
n = 5

2. Enter the while loop:

while (i = n) {

3. At this point, the value of i is 5, so the condition (i = n) is true. The code within the loop executes:

i = i - 1; // i becomes 4
n = n + 1; // n becomes 6

4. The loop condition is re-evaluated:

while (i = n) {

5. At this point, the value of i is 6 and the value of n is 6, so the condition (i = n) is true. The code within the loop executes:

i = i - 1; // i becomes 5
n = n + 1; // n becomes 7

6. The loop condition is re-evaluated:

while (i = n) {

7. At this point, the value of i is 7 and the value of n is 7, so the condition (i = n) is true. The code within the loop executes:

i = i - 1; // i becomes 6
n = n + 1; // n becomes 8

8. The loop condition is re-evaluated:

while (i = n) {

9. At this point, the value of i is 8 and the value of n is 8, so the condition (i = n) is true. The code within the loop executes:

i = i - 1; // i becomes 7
n = n + 1; // n becomes 9

10. The loop condition is re-evaluated:

while (i = n) {

11. At this point, the value of i is 9 and the value of n is 9, so the condition (i = n) is true. The code within the loop executes:

i = i - 1; // i becomes 8
n = n + 1; // n becomes 10

12. The loop condition is re-evaluated:

while (i = n) {

13. At this point, the value of i is 10 and the value of n is 10, so the condition (i = n) is true. The code within the loop executes:

i = i - 1; // i becomes 9
n = n + 1; // n becomes 11

14. The loop condition is re-evaluated:

while (i = n) {

15. At this point, the value of i is 11 and the value of n is 11, so the condition (i = n) is true. The code within the loop executes:

i = i - 1; // i becomes 10
n = n + 1; // n becomes 12

16. The loop condition is re-evaluated:

while (i = n) {

17. At this point, the value of i is
Free Test
Community Answer
How many times is the comparison i > = n performed in the followin...
u can check it by writing manually in a short way.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Question Description
How many times is the comparison i > = n performed in the following program?int i=85, n=5;main() {while (i >= n) { i=i-1; n=n+1;}}a)40b)41c)42d)43Correct answer is option 'C'. Can you explain this answer? for Computer Science Engineering (CSE) 2025 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about How many times is the comparison i > = n performed in the following program?int i=85, n=5;main() {while (i >= n) { i=i-1; n=n+1;}}a)40b)41c)42d)43Correct answer is option 'C'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2025 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for How many times is the comparison i > = n performed in the following program?int i=85, n=5;main() {while (i >= n) { i=i-1; n=n+1;}}a)40b)41c)42d)43Correct answer is option 'C'. Can you explain this answer?.
Solutions for How many times is the comparison i > = n performed in the following program?int i=85, n=5;main() {while (i >= n) { i=i-1; n=n+1;}}a)40b)41c)42d)43Correct answer is option 'C'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of How many times is the comparison i > = n performed in the following program?int i=85, n=5;main() {while (i >= n) { i=i-1; n=n+1;}}a)40b)41c)42d)43Correct answer is option 'C'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of How many times is the comparison i > = n performed in the following program?int i=85, n=5;main() {while (i >= n) { i=i-1; n=n+1;}}a)40b)41c)42d)43Correct answer is option 'C'. Can you explain this answer?, a detailed solution for How many times is the comparison i > = n performed in the following program?int i=85, n=5;main() {while (i >= n) { i=i-1; n=n+1;}}a)40b)41c)42d)43Correct answer is option 'C'. Can you explain this answer? has been provided alongside types of How many times is the comparison i > = n performed in the following program?int i=85, n=5;main() {while (i >= n) { i=i-1; n=n+1;}}a)40b)41c)42d)43Correct answer is option 'C'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice How many times is the comparison i > = n performed in the following program?int i=85, n=5;main() {while (i >= n) { i=i-1; n=n+1;}}a)40b)41c)42d)43Correct answer is option 'C'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev