write a program to find if its divisable by 8 or not
Answers
Answered by
0
Answer:
#include <bits/stdc++.h>
using namespace std;
bool isDiv8(string num){
int n = num.length();
int last_three_digit_val = (num[n-3] - '0') * 100 + (num[n-2] - '0') * 10 + ((num[n-1] - '0'));
if(last_three_digit_val % 8 == 0)
return true;
return false;
}
int main() {
string num = "1754586672360";
if(isDiv8(num)){
cout << "Divisible";
}else{
cout << "Not Divisible";
}
}
Explanation:
Similar questions