C Program To Convert Octal To Decimal Number In One Line

Lets write a C program to convert a number from Octal number system(base 8) to Decimal number system(base 10) in one line.

Related Read:
C Program To Convert Octal Number To Decimal Number, using While Loop

Expected Output for the Input

User Input:
Enter an Octal number
41

Output:
Decimal Representation of Octal Number 41 is 33.

Logic To Convert Octal To Decimal Number In One Line of Code

In c programming language, any octal number(%o format specifier) you store will also be stored in decimal form and you can print it using %d format specifier.

Video Tutorial: C Program To Convert Octal To Decimal Number In One Line


[youtube https://www.youtube.com/watch?v=ifkQ4wDsE6I]

YouTube Link: https://www.youtube.com/watch?v=ifkQ4wDsE6I [Watch the Video In Full Screen.]

Source Code: C Program To Convert Octal To Decimal Number In One Line

#include < stdio.h >

int main()
{
    int num;

    printf("Enter an Octal number\n");
    scanf("%o", &num);

    printf("\nDecimal Representation of Octal Number %o is %d\n", num, num);

    return 0;
}

Output 1:
Enter an Octal number
20

Decimal Representation of Octal Number 20 is 16

Output 2:
Enter an Octal number
51

Decimal Representation of Octal Number 51 is 41

Output 3:
Enter an Octal number
132

Decimal Representation of Octal Number 132 is 90

Output 4:
Enter an Octal number
16

Decimal Representation of Octal Number 16 is 14

Output 5:
Enter an Octal number
40

Decimal Representation of Octal Number 40 is 32

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert

C Program To Convert Decimal To Octal Number In One Line

Lets write a C program to convert a number from Decimal number system(base 10) to Octal number system(base 8) in one line.

Related Read:
C Program To Convert Decimal Number To Octal Number, using While Loop

Expected Output for the Input

User Input:
Enter a Decimal Number
90

Output:
Octal representation of Decimal number 90 is 132

Logic To Convert Decimal To Octal Number In One Line of Code

In c programming language, any decimal number you store will also be stored in Octal form and you can print it using %o format specifier.

Video Tutorial: C Program To Convert Decimal To Octal Number In One Line


[youtube https://www.youtube.com/watch?v=41-xLNYbvDY]

YouTube Link: https://www.youtube.com/watch?v=41-xLNYbvDY [Watch the Video In Full Screen.]

Source Code: C Program To Convert Decimal To Octal Number In One Line

#include < stdio.h >

int main()
{
    int num;

    printf("Enter a Decimal Number\n");
    scanf("%d", &num);

    printf("\nOctal representation of Decimal number %d is %o\n", num, num);

    return 0;
}

Output 1:
Enter a Decimal Number
16

Octal representation of Decimal number 16 is 20

Output 2:
Enter a Decimal Number
41

Octal representation of Decimal number 41 is 51

Output 3:
Enter a Decimal Number
90

Octal representation of Decimal number 90 is 132

Output 4:
Enter a Decimal Number
14

Octal representation of Decimal number 14 is 16

Output 5:
Enter a Decimal Number
32

Octal representation of Decimal number 32 is 40

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert