Computer Applications
Rewrite the following code using for loop.
int i = 1;
int d = 5;
do
{
d = d * 2;
System.out.println(d);
i++;
} while(i <= 5);
Java Iterative Stmts
7 Likes
Answer
int d = 5;
for(int i = 1; i <= 5; i++)
{
d = d * 2;
System.out.println(d);
}
Answered By
6 Likes
Related Questions
Write the Java statement for the following mathematical expression
If a = 8, find the value of a -= ++a + a++ + 4 - a + 6.
Name the operators listed below.
- ?:
- &&
- <=
- ++
Find out the error(s) in the following code and underlining correct error(s).
int m = 5; n = 10; while(n >= 1) { System.out.print("m"); n--; }