number is octal or not

//to check number is octal or not
#include<stdio.h>
#include<conio.h>
void main()
{
int no,r,temp,flag;
clrscr();
printf(“enter your no”);
scanf(“%d”,&no);
temp=no;
for(;no>0;no=no/10)
{
r=no%10;
if(r>=8)
{
flag=0;
break;
}
else
flag=1;
}
if(flag==1)
printf(“octal”);
else
printf(“not octal”);
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *