Decimal to Octal number in c
Decimal to Octal number conversion:
Code:
#include<stdio.h>
int main()
{
int num,i;
scanf("%d",&num);
if(num>=0)
{
for(i=1;i<=num;i*=8)
{}
for(i/=8;i!=1;i/=8)
{
printf("%d",num/i);
num%=i;
}
printf("%d",num);
}
else
{
printf("Can not calculate.\n");
}
return 0;
}
Code:
#include<stdio.h>
int main()
{
int num,i;
scanf("%d",&num);
if(num>=0)
{
for(i=1;i<=num;i*=8)
{}
for(i/=8;i!=1;i/=8)
{
printf("%d",num/i);
num%=i;
}
printf("%d",num);
}
else
{
printf("Can not calculate.\n");
}
return 0;
}
মন্তব্যসমূহ
একটি মন্তব্য পোস্ট করুন