DEV Community

hema latha
hema latha

Posted on

While looping task

package day1;

public class Thanaliraman {

public static void main(String[] args) {
    // TODO Auto-generated method stub
Enter fullscreen mode Exit fullscreen mode

int thenaliraman = 1024;
int balance = thenaliraman-1;
int count = 0;
while(balance>=1)
{
balance =balance/2;
count= count +1;
}
System.out.println(count);
}

}

out put - 10

public class Temple {

public static void main(String[] args) {
    // TODO Auto-generated method stub
//int total_temple = 7;
int final_flower = 1;
//int Initial_flower = 0;
int count = 0;
while(count<=7)
{
final_flower = final_flower * 2;
count = count+1;
}
System.out.println(final_flower);

}
Enter fullscreen mode Exit fullscreen mode

}
out put - 128

Top comments (0)