Computer Science, asked by Anonymous, 1 year ago

What is the outcome of the following loop?

int ctr=0;
while (ctr =0){
System. out. println("This is printed");
}

Answers

Answered by Anonymous
9

Hi

int ctr=0;  

while (ctr =0){

System. out. println("This is printed");  

}

Your code contains an error on second line i.e. while (ctr =0){

in this line you are actually assigning 0 to variable ctr, you are not checking if crt is equals to 0 or not, so this line will throw an error because ctr = 0 will not return Boolean value.

"int cannot be converted to Boolean"


Similar questions