Advertisement
ForcaDz

TP2 : Exo4

Apr 7th, 2023
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.  
  7.     int decimal;
  8.     int reste;
  9.     int binaire = 0;
  10.     int i = 1;
  11.     scanf("%d",&decimal);
  12.  
  13.  
  14.     while (decimal != 0)
  15.     {
  16.         reste = decimal%2 ;
  17.         binaire = binaire + reste * i;
  18.         decimal = decimal / 2;
  19.  
  20.         i = i * 10;
  21.     }
  22.  
  23.     printf("binaire : %d \n",binaire);
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement