Binary, Octal and Hexadecimal Numbers
ตัวอย่างการเขียนด้วยภาษา C
// base_number_1.c
// example of Binary, Octal and Hexadecimal Numbers
#include<stdio.h>
int main(void)
{
int value;
//assigning value in Decimal format
value = 3624;
//printing value in decimal, octal and Hexadecimal format
printf("Decimal: %d, octal: %o, Hexadecimal: %x\n",value,value,value);
//assigning value in binary format
value = 0b111000101000;
//printing value in Decimal, octal and Hexadecimal format
printf("Decimal: %d, octal: %o, Hexadecimal: %x\n",value,value,value);
//assigning value in Octal format
value = 07050;
//pringing value in Decimal, Octal and Hexadecimal format
printf("Decimal: %d, octal: %o, Hexadecimal: %x\n",value,value,value);
//assigning value in Hexadecimal format
value = 0xe28;
//printing value in Decimal, Octal and Hexadecimal format
printf("Decimal: %d, octal: %o, Hexadecimal: %x\n",value,value,value);
return 0;
}ตัวอย่างการเขียนด้วยภาษา C++
ตัวอย่างประยุกต์การแปลงเลขฐานสอง ฐานแปด ฐานสิบหก
Last updated
Was this helpful?