Untitled
unknown
plain_text
a year ago
588 B
5
Indexable
#include <stdio.h> int main() { int n; printf("Enter the number of elements in the sequence: "); scanf("%d", &n); int sequence[n]; printf("Enter the sequence (0s and 1s only):\n"); for (int i = 0; i < n; i++) { scanf("%d", &sequence[i]); } int parity = 0; for (int i = 0; i < n; i++) { parity ^= sequence[i]; } if (parity == 0) { printf("The sequence has even parity (output: 1)\n"); } else { printf("The sequence does not have even parity (output: 0)\n"); } return 0; }
Editor is loading...
Leave a Comment