Advertisement
jasonpogi1669

Finding the Largest Multiple of 10 that is Less than or equal to n using C++

Dec 9th, 2021
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.25 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     ios::sync_with_stdio(false);
  7.     cin.tie(0);
  8.     int n;
  9.     cin >> n;
  10.     int digits = 0;
  11.     while (n > 0) {
  12.         n /= 10;
  13.         digits++;
  14.     }
  15.     cout << pow(10, digits - 1) << '\n';
  16.     return 0;
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement