converters using c

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vijay6
    New Member
    • Mar 2010
    • 158

    converters using c

    How to convert the hexadecimal numbers into its equvalent decimal,binary, octal using the C language?Eg:if ff is the hexadecimal number then its equvalent decimal,binary, octal using C language?
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    How are you getting the number to begin with, as a string, as an integer?
    Do you want to output the number or manipulate it in some other way?
    printf("Decimal %d\n",number);
    printf("Hexadec imal %x\n",number);
    printf("Octal %o\n",number);

    Comment

    • whodgson
      Contributor
      • Jan 2007
      • 542

      #3
      int n=0;
      cin>>n;//enter 0xff
      cout<<dec<<n<<o ct<<n<<endl;//prints n in decimal and octal formats.
      to convert hex to binary convert each hex character to its four digit binary equivalent. e.g.Oxff = 1111 1111 or
      0xabcd = 1010 1011 1100 1101

      Comment

      Working...