bouchnina

decimale to binaire

Dec 5th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. /* Th3 PyRom4n --> Startimes  <--- */
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <conio.h>
  6. #include <math.h>
  7.  
  8. void main()
  9. {
  10. int N,Nmax,i,t[100],c  ;
  11. printf("entrer un nombre en decimal \n ");
  12. scanf("%d",&N);
  13. Nmax=log(N)/log(2);
  14. c=N;
  15. for(i=1;i<=Nmax+1;i++)
  16. {
  17.     t[i]=N%2 ;
  18.     N/=2;
  19. }
  20. printf("le nombre %d en binaire est :",c);
  21. for(i=Nmax+1;i>O;i--)
  22. {
  23.     printf("%d",t[i]);
  24. }
  25.  
  26. printf("\n\n\n\n\n");
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment