Decimal to Octal

#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

Comments (0)

  • To add your comment please or

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

Got It!