Computer Applications
Answer
for (int i = 53; i >= 45; i -= 2)
Reason
- Loop (
i > 45; i -= 2
): The loop starts at 53 and decreases by 2 each time. The values are 53, 51, 49, and 47, which totals 4 iterations before the conditioni > 45
becomes false. - Loop (
i < 57; i++
): The loop starts at 53 and increments by 1 each time. The values are 53, 54, 55, and 56, which totals 4 iterations before the conditioni < 57
becomes false. - Loop (
i >= 45; i -= 2
): The loop starts at 53 and decreases by 2 each time. The values are 53, 51, 49, 47, and 45, which totals 5 iterations before the conditioni >= 45
becomes false. - Loop (
i >= 45; i--
): The loop starts at 53 and decreases by 1 each time. The values range from 53 to 45 inclusive, which totals 9 iterations.
Related Questions
Write a program in Java to find the Fibonacci series within a range entered by the user.
Sample Input:
Enter the minimum value: 10
Enter the maximum value: 20Sample Output:
13Define a class to accept a number and check whether it is a SUPERSPY number or not. A number is called SUPERSPY if the sum of the digits equals the number of the digits.
Example1:
Input: 1021 output: SUPERSPY number [SUM OF THE DIGITS = 1+0+2+1 = 4, NUMBER OF DIGITS = 4 ]
Example2:
Input: 125 output: Not an SUPERSPY number [1+2+5 is not equal to 3]
Give the output of following code and mention how many times the loop will execute?
int i; for( i=5; i>=1; i--) { if(i%2 == 1) continue; System.out.print(i+" "); }
How many times will the following loop execute? Write the output of the code:
int x=10; while (true){ System.out.println(x++ * 2); if(x%3==0) break; }