What is Octal


Printing Integer : %x %o %d format


What would be the Output of this Program?

#include<stdio.h>
void main()
{
printf("%d%o%x",50,050,0x50);
}


Output:  50 50 50


Why ?
  1. %d format specifier is used for Printing Integer
  2. %o format specifier is used for Printing Octal
  3. %x format specifier is used for Printing Hexadecimal
  4. Any number preceded with Zero (040,050,030) are considered as Octal Numbers
  5. Any number preceded with [ 0x / 0X ] (0×40,0×50,0×30) are considered as Hexadecimal Numbers
What is Octal ?
Octal (pronounced AHK-tuhl , from Latin octo or "eight") is a term that describes a base-8 number system. An octal number system consists of eight single-digit numbers: 0, 1, 2, 3, 4, 5, 6, and 7. The number after 7 is 10. The number after 17 is 20 and so forth.
In computer programming, the octal equivalent of a binary number is sometimes used to represent it because it is shorter.
Octal numeral system:
An octal number is a number that consists of any of the following eight (8) symbols or digits 0, 1, 2, 3, 4, 5, 6 and 7. The position of each digit within an octal number denotes the multiplier with power of eight (8) of that digit, e.g. 123 = 1×82 + 2×81 + 3×80 = 64 + 16 + 3 = 83.

Visit: http://www.aqua-calc.com/convert/number/decimal-to-octal to understand the conversion system graphically.

No comments:

Post a Comment