Results 1 to 4 of 4

Thread: Standard binary conversion

  1. #1
    Join Date
    Apr 2009
    Posts
    87

    Standard binary conversion

    For the past few days, i am try to create a small program that would convert a decimal to binary. After much research I found a suitable code that I try to run with my compiler, C but it won't work. Can any one give me example for binary conversion.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Standard binary conversion

    Code:
     void ()
     (
         int n, bin [100], i, j;
         printf ( "Enter A Number To Find It's Binary Equivalence \ n");
         scanf ( "% d", & n);
         printf ( "The Binary equivalent of% d is \ t", n);
         for (i = 0; n! = 0; i + +)
         (
             bin [i] = n% 2;
             n = n / 2;
         )
         for (j = i - 1 j> = 0, j -)
         (
             printf ( "% d", bin [j]);
         )
         printf ( "\ n");
     )

  3. #3
    Join Date
    Jan 2009
    Posts
    199

    Re: Standard binary conversion

    Code:
    #include<stdio.h> 
    #include<conio.h> 
    void main() 
    { 
    
    int i,l,f,q[100]; 
    clrscr(); 
    printf("Enter a Number:"); 
    scanf("%d",&l); 
    i=0; 
    while(;>0) 
    { 
    q[i]=l%2; 
    l=l/2; 
    i++; 
    } 
    printf("\n\nBinary Equivalent:"); 
    f=i-1; 
    for(i=f;f>=0;f--) 
    printf("%d",b[jf); 
    getch(); 
    }

  4. #4
    Join Date
    Dec 2008
    Posts
    177

    Re: Standard binary conversion

    Code:
    #include<iostream.h>
    #include<conio.h>
    void main()
    {
     clrscr();
     unsigned long int j,o=0,k=0,r,l[50];
     unsigned long b,y,c[50];
     cout<<"\nEnter a decimal no. ";
     cin>>b;
     z=b;
     y=b-z;
     while(z>0)
     {
      s=z%2;
      k[i]=r;
      i++;
      z=z/2;
     }
     int n=0;
     while(n<10)
     {
      y=y*2;
      b[k]=int(y);
      k++;
      m++;
      if(y>1)
       y=y-1;
      else
       if(y==0)
        break;
     }
     cout<<"\nDecimal no. "<<b<<" = ";
     if(b>1)
     {
      for(int e=i-1;e>=0;e--)
       cout<<k[e];
      cout<<".";
      for(int d=0;d<n;d++)
       cout<<c[d];
     }
     else
     {
      cout<<"0.";
      for(int f=0;f<n;f++)
       cout<<b[f];
     }
     cout<<" in binary no. system";
     getch();
    }

Similar Threads

  1. binary and text conversion java
    By Ronguor in forum Software Development
    Replies: 1
    Last Post: 14-03-2012, 01:24 PM
  2. Replies: 2
    Last Post: 28-10-2010, 01:56 PM
  3. What are the different binary directories of Mac
    By Spiero in forum Operating Systems
    Replies: 5
    Last Post: 03-03-2010, 01:26 PM
  4. Conversion to binary to real
    By Vodka in forum Software Development
    Replies: 5
    Last Post: 02-03-2010, 12:03 PM
  5. Date & time Conversion PST Pacific Standard Time to GMT
    By Austinage in forum Software Development
    Replies: 2
    Last Post: 30-07-2009, 05:38 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,490,178.78256 seconds with 17 queries