Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- short getBit(short value, short position) {
- return ((1 << position) & value) >> position;
- }
- int main() {
- short value = 128;
- int ones = 0;
- int i = 0;
- for (; i < 7; i++)
- ones += getBit(value, i);
- //neparni paritet
- if (ones % 2 != getBit(value, 7))
- printf("Podatak je ispravan");
- else printf("Podatak nije ispravan");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement