Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. #include<conio.h>
  2. #include<stdlib.h>
  3.  
  4. void reve (char a[500])
  5. { int i,n=0;
  6. char aux;
  7. while(a[n]!='\0')
  8.     n++;
  9. n--;
  10. for(i=0;i<=n/2;i++)
  11. {
  12.     aux=a[i];
  13.     a[i]=a[n-i];
  14.     a[n-i]=aux;
  15. }}
  16.  
  17. void BinVal ()
  18. {
  19.     char n,s[10];
  20.     scanf("%s",&n);
  21.     int x;
  22.     x=n;
  23.     itob(n,s,2);
  24.     reve(s);
  25.     printf("%s ",s);
  26.     get(s,4);
  27. }
  28.  
  29. void itob (int n, char s[], int b)
  30. {  int a,i=0,c;
  31.     char remainder[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','E','F'};
  32.  
  33.  while(n!=0)
  34.     {
  35.         a=n%b;
  36.         s[i++]=remainder[a];
  37.         n=n/b;
  38.     }
  39.     s[i]='\0';
  40. }
  41.  
  42. unsigned char get (unsigned char x[100], unsigned char n)
  43. {  
  44.     return x[n];
  45.     printf("%d",x[n]);
  46.  
  47. }
  48. void set (unsigned char variable, unsigned char n, unsigned char value)
  49. {
  50.  
  51.  
  52. }
  53.  
  54.  
  55.  
  56. int main()
  57. {
  58.     BinVal();
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement