**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 ?**

- %d format specifier is used for Printing Integer
- %o format specifier is used for Printing Octal
- %x format specifier is used for Printing Hexadecimal
- Any number preceded with Zero (040,050,030) are considered as Octal Numbers
- 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×8

^{2}+ 2×8^{1}+ 3×8^{0}= 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