Convert binary, hexadecimal number added

Source: Internet
Author: User

Direct Sticker Code

#include"stdio.h"intMain () {intNum, NUM1, r, n =0; Chardtor[ +]; printf ("Please enter the number to convert:"); scanf ("%d",&NUM1); Num=NUM1; printf ("number to convert to binary (2~16)"); scanf ("%d",&R);  Do    {        if(num% r >=Ten) Dtor[n]= num%r+ -; ElseDtor[n]= num%r+ -; Num= num/R; if(num = =0) Break; N++; } while(1); printf ("decimal number%d and%d binary numbers", Num1,r);  for(; n >=0; n--) printf ("%c", Dtor[n]); printf ("equivalent");}

Hexadecimal number Addition

#include <stdio.h>intMain () {__int64 A, B; //because the defined number has a maximum length of 16 bits, it is defined as int64     while(SCANF ("%i64x%i64x", &a,&b)! =EOF) printf (a+b>=0?"%i64x\n":"-%i64x\n",a+b>0? a+b:-a-b);//It is the perfect application of the three-mesh operator to examine the output format of the problem.     return 0;}

Convert binary, hexadecimal number added

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.