fork download
  1. #include <stdio.h>
  2. int main(void)
  3. {
  4. //declare data and variable type
  5. int count;
  6. int a, b;
  7. //assigning values for a and b trough the user
  8. printf("Enter a:\n");
  9. scanf("%d", &a);
  10. printf("Enter b:\n");
  11. scanf("%d", &b);
  12. //while loop deciding if a is divided by b
  13. for (count = 1; count <= a; count++) {
  14. if (a % b == 0) {
  15. printf("%d is divisible by %d\n", a, b);
  16. }
  17. else {
  18. printf("%d is not divisible by %d\n", a, b);
  19. }}
  20. return 0 ;}
Success #stdin #stdout 0s 9432KB
stdin
10 2
stdout
Enter a:
Enter b:
10 is divisible by 2
10 is divisible by 2
10 is divisible by 2
10 is divisible by 2
10 is divisible by 2
10 is divisible by 2
10 is divisible by 2
10 is divisible by 2
10 is divisible by 2
10 is divisible by 2