Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int a, n, c[ 100 ], i, j,d ;
- while((scanf("%d",&n))==1)
- {
- for(i=0 ; n>0 ; i++)
- {
- c[i]=n%2;
- n=n / 2;
- }
- i=i-1;
- d=0;
- for(j=i ; j>=0 ; j--){
- printf ("%d",c [j]);
- if(c[j]==1)
- d++;
- }
- printf("\n%d\n",d);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment