# Printing value in Decimal, Octal, Hexadecimal using printf in C

This code snippet will print an entered value in Decimal, Octal and Hexadecimal format using printf() function in C programming language. By using different format specifier we can print the value in specified format.

## Print value in Decimal, Octal ad Hex using printf() in C

```/*Printing value in Decimal, Octal, Hexadecimal using printf in C.*/

#include <stdio.h>

int main()
{
int value=2567;

printf("Decimal value is: %d\n",value);
printf("Octal value is: %o\n",value);
printf("Hexadecimal value is (Alphabet in small letters): %x\n",value);
printf("Hexadecimal value is (Alphabet in capital letters): %X\n",value);

return 0;
}
```

Output

```
Decimal value is: 2567
Octal value is: 5007
Hexadecimal value is (Alphabet in small letters): a07
Hexadecimal value is (Alphabet in capital letters): A07

```

Here, following format specifiers are used:

• %d - to print value in integer format
• %o - to print value in octal format
• %x - to print value in hexadecimal format (letters will print in lowercase)
• %X - to print value in hexadecimal format (letters will print in uppercase)

What's New

Top Interview Coding Problems/Challenges!

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates