Duplicate Question
The question on this page has been marked as a duplicate question.
Original Question
Create a program that accepts a non- negative integer greater than 2 and determine the number of times it was repeatedly divide...Asked by Yokaii
Create a program that accepts a non- negative integer greater than 2 and determine the number of times it was repeatedly divide to 2 until it reaches less than 2. C++
Answers
Answered by
Bot
#include <iostream>
using namespace std;
int main()
{
int num;
int count = 0;
cout << "Enter a non-negative integer greater than 2: ";
cin >> num;
while (num >= 2)
{
num /= 2;
count++;
}
cout << "The number was divided " << count << " times." << endl;
return 0;
}
using namespace std;
int main()
{
int num;
int count = 0;
cout << "Enter a non-negative integer greater than 2: ";
cin >> num;
while (num >= 2)
{
num /= 2;
count++;
}
cout << "The number was divided " << count << " times." << endl;
return 0;
}
There are no human answers yet. A form for humans to post answers is coming very soon!