#include <stdio.h>
// Function to find the next largest number greater than A and B that is divisible by B
int nextLargestDivisible(int A, int B) {
int integer = (A > B) ? A + 1 : B + 1; // Start with the larger of (A + 1) or (B + 1)
while (integer % B != 0) { // Keep incrementing until divisible by B
integer++;
}
return integer;
}
int main() {
int A, B;
// Prompt user for input
printf("Enter the value of A: ");
scanf("%d", &A);
printf("Enter the value of B: ");
scanf("%d", &B);
// Call the function and display the result
int result = nextLargestDivisible(A, B);
printf("The first number greater than both %d and %d that is divisible by %d is: %d\n", A, B, B, result);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: