Computer Science, asked by ishasingh1234, 9 months ago

b) State output and how many times will the loop run
int i;
for(int i=5;i>=1;i--)
if(i%2==0)
continue;
System.out.println(i+" ");​

Answers

Answered by sunitazirange
1

Answer:

first of all it will display an error that variable i is already defined and if you remove int in that for loop then,the program will be like this !

public class loop

{

public static void main(String []args)

{

int i;

for(i=5;i>=1;i--){

if(i%2==0){

continue;

System.out.println(i+" ");

}

}

}

}

SO THE ANS IS YOU WILL GET AN ERROR..........!

IF YOU WANTED A CORRECT PROGRAM THEN THE PROGRAM MUST BE LIKE THIS !

public class loop

{

public static void main(String []args)

{

int i;

for(i=5;i>=1;i--){

if(i%2==0){

System.out.println(i+" ");

}

}

System.out.println();

}

}

your program will be compiled but the output will be unsatisfactory

which is

4

2

so your ultimate ans , according to your question asked by you is you will get an error so no output and the number of loops will not be there.

hope it helps!

plz mark me as brainliest!

Similar questions