Computer Applications
Convert the given loop into exit-controlled loop.
int a, b;
for(a = 10, b = 1; a >= 1; a -= 2){
b += a;
b++;
}
System.out.print(b);
Java Iterative Stmts
10 Likes
Answer
int a = 10, b = 1;
do {
b += a;
b++;
a -= 2;
} while(a >= 1);
System.out.print(b);
Answered By
6 Likes
Related Questions
Write the output of the following String method:
String x = "talent"; String y = "matrix"; System.out.println(x.substring(3).concat(y.substring(3)));Write the Java statement for creating an object named 'sifra' of the class 'Robot', which takes three double parameters.
Consider and give the output of the following program:
class report{ int a, b; report(){ a = 10; b = 15; } report(int x, int y){ a = x; b = y; } void print(){ System.out.println(a * b); } static void main(){ report r = new report(); r.print(); report p = new report(4, 5); p.print(); } }(a) Name one String method which results in positive integer only.
(b) Name one String method which results in a character.