944,087 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2882
  • C RSS
Apr 22nd, 2006
0

Help! Decimal to binary conversion

Expand Post »
This program converts a decimal input into a hexadecimal and octal value.But I also want to convert it top binary as well.So kindly guide me.
thanx
  1. #include<stdio.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. int a;
  7. printf("Enter a number");
  8. scanf("%d",&a);
  9. printf("Decimal=%d",a);
  10. printf("\nOctal=%o",a);
  11. printf("\nHexadecimal=%x",a);
  12.  
  13. getch();
  14. }
Last edited by Dave Sinkula; Apr 23rd, 2006 at 5:35 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
john_hasan is offline Offline
5 posts
since Apr 2006
Apr 22nd, 2006
0

Re: Help! Decimal to binary conversion

I think the whole point of this exercise is for you to write a function along the lines of
  1. void convertToBase( int number, int base, char *result );

Assuming you know how to do this for base 10, through application of the / and % operators, the rest should follow naturally.
Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: strcmp without cast
Next Thread in C Forum Timeline: Strings: Case Insensitive strstr





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC