pablosotol

Guia Programacion 1 - Ejercicio 19

Apr 3rd, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.19 KB | None | 0 0
  1. #include<stdio.h>
  2. int main(){
  3. int x,i=0,c,cont=0;
  4. printf("Escriba un numero: ");
  5. scanf("%d",&x);
  6. for(i=1;i<=30;i++){
  7. if(x&1==1)cont+=1;
  8. x>>=1;
  9. }
  10. printf("Hay %d bits activos",cont);
  11. }
Advertisement
Add Comment
Please, Sign In to add comment