- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Check if a large number is divisible by 20 in C++

Here we will see how to check a number is divisible by 20 or not. In this case the number is very large number. So we put the number as string.

A number will be divisible by 20, when that is divisible by 10, and after dividing 10, the remaining number is divisible by 2. So the case is simple. If the last digit is 0, then it is divisible by 10, and when it is divisible by 10, then the second last element is divisible by 2, the number is divisible by 20.

## Example

#include <bits/stdc++.h> using namespace std; bool isDiv20(string num){ int n = num.length(); if(num[n - 1] != '0') return false; int second_last = num[n - 2] - '0'; if(second_last % 2 == 0) return true; return false; } int main() { string num = "54871584540"; if(isDiv20(num)){ cout << "Divisible"; }else{ cout << "Not Divisible"; } }

## Output

Divisible

- Related Questions & Answers
- Check if a large number is divisible by 11 or not in java
- Check if a large number is divisible by 3 or not in java
- Check if a large number is divisible by 13 or not in C++
- Check if a large number is divisible by 11 or not in C++
- Check if a large number is divisible by 25 or not in C++
- Check if a large number is divisible by 3 or not in C++
- Check if a large number is divisible by 5 or not in C++
- Check if a large number is divisible by 75 or not in C++
- Check if a large number is divisible by 8 or not in C++
- Check if a large number is divisible by 9 or not in C++
- Check if any permutation of a large number is divisible by 8 in Python
- Check if any large number is divisible by 17 or not in Python
- Check if any large number is divisible by 19 or not in Python
- Check if a large number is divisible by 2, 3 and 5 or not in C++
- Check if a large number is divisibility by 15 in C++

Advertisements