Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int A[20], n, i;
- int invalid = 1, valid = 1; // 2 for unused value
- int count = 0;
- printf("Enter number of inputs :");
- scanf("%d", &n);
- if (n >= 1)
- {
- printf("Enter %d inputs :\n", n);
- for (int j = 1; j <= n; j++)
- {
- scanf("%d", &A[j]);
- }
- for (i = 1; i <= n; i++)
- {
- if (A[i] % 3 == 0)
- {
- valid = 1;
- }
- else
- {
- invalid = 0;
- }
- }
- }
- else
- {
- printf("Your inputs are not valid.\n");
- }
- switch (valid * invalid)
- {
- case 1:
- {
- printf("Congrats, Your string is valid \n");
- break;
- }
- case 0:
- {
- printf("Your string is not valid\n");
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement