Computer Science, asked by pratimabaraily71, 8 months ago

Write an algorithm and draw a flowchart to check if a number is divisible by 17 or not ​

Answers

Answered by sujeevana2007
0

Answer:

// CPP Program to validate the above logic

#include <bits/stdc++.h>

using namespace std;

// Function to check if the

// number is divisible by 17 or not

bool isDivisible(long long int n)

{

while (n / 100)

{

// Extracting the last digit

int d = n % 10;

// Truncating the number

n /= 10;

// Subtracting the five times the

// last digit from the remaining number

n -= d * 5;

}

// Return n is divisible by 17

return (n % 17 == 0);

}

// Driver code

int main()

{

long long int n = 19877658;

if (isDivisible(n))

cout << "Yes" << endl;

else

cout << "No" << endl;

return 0;

}

Similar questions