• Source
    1. #include<stdio.h>
    2. int main()
    3. {
    4. int n,i,x;
    5. printf(" Please, Enter a Number : ");
    6. scanf("%d",&n);
    7. printf("\n The binary equivalent of the number : \n ");
    8. for(i=7;i>=0;i--)
    9. {
    10. x=n&(1<<i);
    11. if(x==0)
    12. printf("0");
    13. else
    14. printf("1");
    15. }
    16. n=~n;
    17. printf("\n The 1's complement of the number :\n ");
    18. for(i=7;i>=0;i--)
    19. {
    20. x=n&(1<<i);
    21. if(x==0)
    22. printf("0");
    23. else
    24. printf("1");
    25. }
    26. return 0;
    27. }