Advertisement
Shailrshah

Printing Elements divisible by 3 & 7

Apr 18th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     int a[100];
  5.     int n,i;
  6.     printf("Enter the array's limit: ");
  7.     scanf("%d",&n);
  8.     printf("Now enter %d elements.\n",n);
  9.     for(i=0;i<n;i++)
  10.         scanf("%d",&a[i]);
  11.     for(i=0; i<n; i++)
  12.     {
  13.         if(a[i]%3 == 0)
  14.             printf("%d is divisible by 3\n",a[i]);
  15.         if(a[i]%7 == 0)
  16.             printf("%d is divisible by 7\n",a[i]);
  17.     }
  18.     return 0;
  19. }
  20. //Output
  21. //Enter the array's limit: 5
  22. //Now enter 5 elements.
  23. //3
  24. //6
  25. //7
  26. //12
  27. //14
  28. //3 is divisible by 3
  29. //6 is divisible by 3
  30. //7 is divisible by 7
  31. //12 is divisible by 3
  32. //14 is divisible by 7
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement