package B14;
public class num30 {
public static void main(String[] args) {
int police = 0;
int theif = 40;
while (police <= theif) {
police = police + 5;
theif = theif + 2;
}
System.out.println(police);
}
}
Output:70
package B14;
public class num31 {
public static void main(String[] args) {
int gift = 1024;
int count=0;
while (gift > 1) {
gift = gift / 2;
count++;
System.out.print(gift+" ");
}System.out.println(" total count is---> "+count);
}
}
Output:512 256 128 64 32 16 8 4 2 1 total count is---> 10
package B14;
public class num32 {
public static void main(String[] args) {
int no = 1;
int count = 1;
while (count <= 7) {
no = no * 2;
count = count + 1;
}
System.out.println(no);
}
}
**
Output:128**
Top comments (0)