Easiest Way to Convert Decimal Numbers to Octal Number in C Programming Language

in #programming7 years ago

// Codes that will take input from the user in Decimal & convert it into Octal in C programming language

#include <stdio.h>
int main ()
{
int num, re,re2,sum=0, oct = 0;
printf("Decimal: ");
scanf("%d", &num);

while (num > 0)
{
    re = num % 8;
    oct = (oct * 10) + re;
    num = num / 8;
}


while (oct>0)
{
    re2 = oct % 10;

    sum = (sum * 10) + re2;
    oct = oct / 10;
}
printf("Octal: %d\n", sum);

}

Sort:  

thanks sweetheart

tor mayre baap :v

tor fadar madar

vai asob ki likhsen mia ??

he he mia 69 likhle vlo hoito

Excecelent Post

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by riyasaat from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, and someguy123. The goal is to help Steemit grow by supporting Minnows and creating a social network. Please find us in the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you like what we're doing please upvote this comment so we can continue to build the community account that's supporting all members.

Coin Marketplace

STEEM 0.16
TRX 0.15
JST 0.028
BTC 58949.08
ETH 2306.78
USDT 1.00
SBD 2.47