C Programming

Decimal to Octal

Learn C programming for convert decimal number to octal number

6/2/2018
0 views
decimal-to-octal.cC
#include<stdio.h>

int main() {
	int decimal, octal = 0, i = 1;
	printf("Welcome to Decimal to Octal converter\n");
	printf("Enter a decimal number:\n");
	scanf("%d",&decimal);
	while(decimal != 0) {
		octal += (decimal % 8) *i;
		i *= 10;
		decimal /= 8;
	}
	printf("Octal value is: %d\n",octal);
	return 0;
}



/* Output */
Welcome to Decimal to Octal converter
Enter a decimal number:
8

Octal value is: 10
C programmingC codingdecimal to octal conversationdecimal to octal converter

Related Examples