Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int NumM, NumK, Num;
- bool IsCorrect;
- Num = 4;
- NumK = 0;
- cout << "Given an integer m > 10. Find the largest integer k for which 4^k <
- m.\n";
- cout << "Enter integer (>10): ";
- do
- {
- IsCorrect = false;
- cin >> NumM;
- if ((cin.fail()) or (NumM < 10))
- {
- IsCorrect = true;
- cout << "Incorrect value. Enter the number: ";
- }
- cin.clear();
- while (cin.get() != '\n');
- } while (IsCorrect);
- while (Num < NumM)
- {
- Num = Num * 4;
- NumK = NumK + 1;
- }
- cout << NumK;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement