is there any way to count how many times the do while loop occurred for example:
a = 4
b = 7
i know i should return as 2 but im not quite sure on how to implement it
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <iostream>
#include <cmath>
usingnamespace std;
int main()
{
int a;
int b;
cin >> a >> b;
do
{
a*=3;
b*=2;
} while (a<=b);
return 0;
}
#include <iostream>
#include <cmath>
usingnamespace std;
int main()
{
int a;
int b;
int loopCount{};
// <--- Needs a prompt. Unless you like looking at a blank screen.
cin >> a >> b;
do
{
a*=3;
b*=2;
loopCount++;
} while (a<=b);
std::cout << "\n loopCount = " << loopCount << '\n';
return 0;
}