Sat Jun 02 2018

Decimal to Octal

C Programming3581 views

File Name: decimal-to-octal.c

#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
Reference:

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.