TCS Coding Problem 9

17 comments on “TCS Coding Problem 9”


  • Kanchi

    a=float(input()) #25.625
    if a==int(a):
    a=int(a)
    temp=””
    while a!=0:
    temp=str(a%8)+temp
    a=a//8
    print(temp)
    else:
    number=int(a)
    decimal=a-int(a)
    temp1=””
    while number!=0:
    temp1=str(number%8)+temp1
    number=number//8
    temp2=””
    while decimal!=0:
    temp2=temp2+str(int(decimal*8))
    decimal=(decimal*8)-int(decimal*8)
    print(float(temp1)+float(int(temp2)/(10**len(temp2))))


  • sai

    void convertdectooct()
    {
    int n=350;
    String s=””;
    if(n8){
    if(n/8>8)
    {
    s=s.concat(Integer.toString(n%8));
    }
    else
    {
    s=s.concat(Integer.toString(n%8)).concat(Integer.toString(n/8));
    }
    n=n/8;
    }

    for (int i = s.length()-1; i >=0 ; i–) {

    System.out.print(s.charAt(i));
    }

    }


  • Vkjha

    a=int(input())
    d=[]
    b=a//8
    e=a%8
    d.append(b)
    d.append(e)
    print(str(d[0])+str(d[1]))