Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int A[20], n, i;
  5. int invalid = 1, valid = 1; // 2 for unused value
  6. int count = 0;
  7. printf("Enter number of inputs :");
  8. scanf("%d", &n);
  9. if (n >= 1)
  10. {
  11. printf("Enter %d inputs :\n", n);
  12. for (int j = 1; j <= n; j++)
  13. {
  14. scanf("%d", &A[j]);
  15. }
  16. for (i = 1; i <= n; i++)
  17. {
  18. if (A[i] % 3 == 0)
  19. {
  20. valid = 1;
  21. }
  22. else
  23. {
  24. invalid = 0;
  25. }
  26. }
  27. }
  28. else
  29. {
  30. printf("Your inputs are not valid.\n");
  31. }
  32. switch (valid * invalid)
  33. {
  34. case 1:
  35. {
  36. printf("Congrats, Your string is valid \n");
  37. break;
  38. }
  39. case 0:
  40. {
  41. printf("Your string is not valid\n");
  42. break;
  43. }
  44. }
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement