- Related Questions & Answers
- Add N digits to A such that it is divisible by B after each addition?
- Minimum positive integer value possible of X for given A and B in X = P*A + Q*B in C++
- PHP program to find the sum of first n natural numbers that are divisible by a number ‘x’ or a number ‘y’
- Find multiple of x closest to or a ^ b (a raised to power b) in C++
- Maximum positive integer divisible by C and is in the range [A, B] in C++
- Minimum positive integer divisible by C and is not in range [A, B] in C++
- Add N digits to A such that it is divisible by B after each addition in C++?
- Program to find Nth term divisible by a or b in C++
- How can we match the values having backslashes, like ‘a\\b’, from MySQL column?
- Program to build DFA that starts and ends with ‘a’ from the input (a, b)
- Program to build DFA that starts and end with ‘a’ from input (a, b) in C++
- Find a palindromic string B such that given String A is a subsequence of B in C++
- Find the multiple of x which is closest to a^b in C++
- Find N Arithmetic Means between A and B using C++.
- Find N Geometric Means between A and B using C++.

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

Given with equation program must find the value of ‘a’ where a+b<=n and also divisible by x.

START Step 1 -> Declare start variables b=10, x=9, n=40 and flag=0, divisible Step 2 -> Loop For divisible = (b / x + 1 ) * x and divisible <= n and divisible += x IF divisible - b >= 1 Print divisible-1 Set flag=1 End END STOP

#include <stdio.h> int main(int argc, char const *argv[]) { int b=10, x=9, n=40, flag = 0; int divisible; for (divisible = (b / x + 1 ) * x ; divisible <= n; divisible += x) { if ( divisible - b >= 1) { printf("%d ", divisible - b ); flag = 1; } } return 0; }

if we run above program then it will generate following output

8 17 26

Advertisements