Site icon T4Tutorials.com

How to convert for loop program into Do while loop?

How to convert for loop program into Do while loop? How to convert Do while loop into for loop program?

For loop into Do while loop conversion. Do while loop into For loop conversion.

For loop program

#include<iostream>
using namespace std;
int main()
{
	int outer, innermost, s;
	for(outer=1; outer<=5; outer++)
	{
	cout<<"1";
	cout<<endl;
	}
}

Output

1

1

1

1

1

How to convert for loop program into Do while loop?

Step 1:

How to convert for loop program into Do while loop c++

Step 2:

How to convert Do while loop program into for loop C++

Step 3:

Do while loop to for loop converter logic and help C++

Step 4:

for loop to Do while loop converter logic and help C++

Do while loop program

#include<iostream>
using namespace std;
int main()
{
	int outer, innermost, s;
	outer=1;
	do
	{
	cout<<"1";	
	cout<<endl;
	outer++;
	}
	while(outer<=5);
}

Output

1

1

1

1

1
shamil memory table

Exit mobile version