Subscribe Us

Convert Hexa-decimal to Octal in C - smartduniya

C program-convert Hexa-Decimal Number to Octal Number:

 C program-convert Hexa-Decimal Number to Octal Number

To covert Hexa-Decimal Number to Octal Number in C programming , It is very easy. I will tell you the easiest way without any function without Array[] .You think How ? ok..let's read the post We all know about Ocatal and Hexa- decimal Number.Hexa-Decimal Number has 16 base(0-F) and Octal Number has 8 base(0-7 digit).

As the same process we use in c programming .Hope you know basic C program . In C program we use '%c' for any character . Same we use here '%x' for Hexa- decimal and '%o' for octal Number. It is the easiest way to convert Octal to Decimal.
In this post we will learn , how to convert Any Hexa-Decimal Number to Octal Number by c programming. From above we get some basic knowledge about Hexa-Decimal and Octal value.


See the table of octal and Hexa-decimal number . You get a clear idea about the octal and Hexa-decimal number.


 
Hexa-Decimal Octal
0 0
1 1
2 2
7 7
8 10
9 11
A 12
B 13
C 14
D 15
E 16
F 17
1A 32
1F 37

Let's learn , How to convert Hexa-Decimal to Octal through a problem.

It is a good practice any program through the problem,It will help to remember the program and better understand the program.When you learn something always try to implement.

Let Suppose a problem is :

Any input through the keyboard . Write a program to convert Hexa-Decimal Number to Octal Number in C ?.


>>To solve this problem ,

>>> we have to take '%x' for Hexa-decimal and '%o' for octal Number.
It is the easy way to convert Hexa-Decimal Number to Octal Numberr.
You have many qustion , many doubts right now.I will cleare all.

If I input '1A' as a hexa decimal number, it's octal value is 32 . If you run the program and give any hexa decimal number and hit enter button you will get octal number.

Let's Go to the code :
hexa-decimal to octal

Note :Click on the button to copy the text from the text field. Try to paste the text (e.g. ctrl+v) afterwards in a different window, to see the effect.

write the above code in your compiler or copy this code and paste . save this with '.c ' extension.In this screen User have to input a number to convert Hexa-Decimal Number to Octal Number .First input a Hexa-decimal value Then press Enter to show octal value.

Out put :

hexa-decimal to octal

Hope you understand if you face any problem comment below ,will try to help you.

 

Don’t forget to Subscribe our Blog to get update. Just put your email on subscribe box and hit subscribe button , next verify your email , it will be done.

You will get every single post when we will upload in Smartduniya.


Also learn this post :


How to write comment in C ?

How to write keyword, identifires in C ?

How to write Printf() function in C ?

Post a Comment

0 Comments