
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Check if a large number is divisible by 25 or not in C++
Here we will see how to check a number is divisible by 25 or not. In this case the number is very large number. So we put the number as string.
A number will be divisible by 25, when the last two digits are 00, or they are divisible by 25.
Example
#include <bits/stdc++.h> using namespace std; bool isDiv25(string num){ int n = num.length(); int last_two_digit_val = (num[n-2] - '0') * 10 + ((num[n-1] - '0')); if(last_two_digit_val % 25 == 0) return true; return false; } int main() { string num = "451851549333150"; if(isDiv25(num)){ cout << "Divisible"; } else { cout << "Not Divisible"; } }
Output
Divisible
- Related Articles
- 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 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 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 2, 3 and 5 or not in C++
- 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 number is divisible by 23 or not in C++
- Check if a number is divisible by 41 or not in C++
- Check if a large number is divisible by 20 in C++

Advertisements