Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- long long int a,c;
- int i=0,count=0 , p;
- char s[10 ^ 10000];
- while(scanf("%lld",&a) == 1)
- {
- if(a == 0)
- break;
- printf("The parity of ");
- c = a;
- i = 0;
- count = 0;
- while(a != 0)
- {
- s[i] = a % 2;
- a =a / 2;
- count++;
- i++;
- }
- p = 0;
- for(i = count - 1; i>= 0; i--)
- {
- printf("%d",s[i]);
- if(s[i] == 1)
- p++;
- }
- printf(" is %d (mod 2).\n",p);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement