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
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
Science,
2 months ago
Science,
2 months ago
Math,
4 months ago
Computer Science,
4 months ago
Geography,
10 months ago
World Languages,
10 months ago