| | |
Help! Decimal to binary conversion
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Apr 2006
Posts: 5
Reputation:
Solved Threads: 0
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
thanx
C Syntax (Toggle Plain Text)
#include<stdio.h> #include<conio.h> void main() { clrscr(); int a; printf("Enter a number"); scanf("%d",&a); printf("Decimal=%d",a); printf("\nOctal=%o",a); printf("\nHexadecimal=%x",a); getch(); }
Last edited by Dave Sinkula; Apr 23rd, 2006 at 5:35 pm.
I think the whole point of this exercise is for you to write a function along the lines of
Assuming you know how to do this for base 10, through application of the / and % operators, the rest should follow naturally.
C Syntax (Toggle Plain Text)
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.
![]() |
Similar Threads
- Help With Decimal to Binary conversion (IT Professionals' Lounge)
- Convert decimal to binary and with base the 8 (C)
- decimal to binary conversion (C++)
- decimal > binary > Oct > Hex (C++)
Other Threads in the C Forum
- Previous Thread: strcmp without cast
- Next Thread: Strings: Case Insensitive strstr
| Thread Tools | Search this Thread |
#include adobe ansi api append array arrays asterisks binarysearch changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc csyntax database directory dynamic execv feet fgets file fork framework frequency function getlasterror givemetehcodez global grade gtkgcurlcompiling hacking hardware highest histogram include incrementoperators infiniteloop input interest kernel keyboard kilometer license linked linkedlist linux linuxsegmentationfault list lists locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft motherboard mqqueue number odf opensource overwrite owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing scripting segmentationfault sequential socket socketprograming standard string systemcall testing threads turboc unix user voidmain() wab windows.h windowsapi






