0

Hello everyone this is the correct ans for your problem....this program is working propely but but int thing is that i can't solve is that the decimal number range between 1 to 7. if any character in my number will increase from 7 thou it shuold give output the number is invalid but but i can't do this if anyone can solve this problem thou plz tell me abou it.......

```
#include <stdio.h>
#include <conio.h>
int octaltodecimal(int x);
void main ()
{
int a,decimal;
printf("Enter an integer = ");
scanf("%d", &a);
decimal=octaltodecimal(a);
printf("%d",decimal);
getch();
}
int octaltodecimal(int x)
{
int base8,m,y,z,n,lastDigit,dec;
lastDigit=x%10;
n=0;
y=x;
if(x>10)
{
z=y%10;
while (y != z)
{
y=y/10;
z=y%10;
base8=z*8^n;
n=n+1;
}
}
dec=base8+lastDigit;
return dec;
}
```

*Edited 5 Years Ago by Narue*: added code tags