#include<iostream>
usingnamespace std;
int main(){
int a= 10;
int b=6;
int e;
if (a<b){e=a;}
else
{e=b;}
for (int i=2; i<=e; i++)
{
if (a%i==0)
a=a/i;
cout <<a<<" " <<i<<endl;
}
return 0;
}
Are you referring to a nested loop by any chance that only activates when i is a specific value? In this example I just had it output i when it was equal to 3, but if you wanted to stop the loop you can use break instead. If you are looking to stop the outer loop, however, then an if statement within the loop that checks for the desired value can implement the break command.
int main()
{
int a= 10,b=6,e;
if (a<b)
e=a;
else
e=b;
for (int i=2; i<=e; i++)
{
if (a%i==0)
a=a/i;
do
{
cout<<i;
} while (i==3);//end of do/while loop
if (i==3)
break;
cout <<a<<" " <<i<<endl;
}//end of for loop
return 0;
}