!Given an octal number (a number in base 8) of arbitrary length write a program to
!find its decimal equivalent of the octal number 2673 is
!2*8**3+6*8**2+7*8**1+3*8**0
program octal_decimal
implicit none
integer::octal_num,decimal_num,octal_digit,decimal_digit,i
decimal_num=0
i=-1
print*,"Input the octal number"
read*,octal_num
print*,"The Octal number is=",octal_num
do
if(octal_num==0)then
exit
else
octal_digit=mod(octal_num,10)
octal_num=octal_num/10
i=i+1
decimal_num=octal_digit*(8**i)+decimal_num
endif
enddo
print*,"Decimal equivalent number is=",decimal_num
print*,"last power",i
end program octal_decimal
!find its decimal equivalent of the octal number 2673 is
!2*8**3+6*8**2+7*8**1+3*8**0
program octal_decimal
implicit none
integer::octal_num,decimal_num,octal_digit,decimal_digit,i
decimal_num=0
i=-1
print*,"Input the octal number"
read*,octal_num
print*,"The Octal number is=",octal_num
do
if(octal_num==0)then
exit
else
octal_digit=mod(octal_num,10)
octal_num=octal_num/10
i=i+1
decimal_num=octal_digit*(8**i)+decimal_num
endif
enddo
print*,"Decimal equivalent number is=",decimal_num
print*,"last power",i
end program octal_decimal