Computer Science, asked by mansuraahmed01, 4 months ago

Rewrite the following program segment using for loop: (2)

char ans= ‘A’;

int x = 2;

do

{ x++ ;

System.out.println(x+ "\t"+ans) ;

ans+=2 ;

} while(x<7) ;

Answers

Answered by BrainlyProgrammer
1

Question:-

  • Convert do-while to for loop

__________________

Given code:-

char ans='A';

int x=2;

do

{

x++;

System.out.println(x+"\t"+ans);

ans+=2;

}while(x<7);

___________________

After converting into for loop....

char ans='A';

for(int x=2;x<7;x++)

{

System.out.println(x+"\t"+ans);

ans+=2;

}

Similar questions