Skip to main content

PROGRAM TO FIND OCTAL OF A NUMBER



LIST OF PROGRAMS


#include<stdio.h>
#include<conio.h>
void main()
{
long int n,oct=0,r=1,pow=1;
 clrscr();

printf("Enter a number ");
scanf("%ld",&n);

if(n<0)
printf("WRONG INPUT");

else
{
 if(n<=7&&n>=0)
 oct =n;

 else
 {
 while(n>0)
 {
r=n%8;
oct=oct+(r*pow);
n=n/8;
pow=pow*10;
 }
 }

 printf("OCTAL = %ld",oct);
 getch();
}
}

LIST OF PROGRAMS

Comments

Anonymous said…
what is this octal?
anuj batham said…
thank for your comment
octal is a type of number system having digits from 1 to 7

Popular posts from this blog

unix commands