Practical 12 Write a program to find the square root of given number.(Assume your number is square).



domains
            No,Temp,Temp1=integer
predicates
            go
            sqroot(No,Temp)
clauses
go:-
            write("Enter the number: "),nl,
            readint(No),
            Temp=1,
            sqroot(No,Temp).
           
            sqroot(No,Temp):-
            (Temp*Temp)>=No,
                        write(Temp),nl.
                       
            sqroot(No,Temp):-
                        Temp1=Temp+1,
            sqroot(No,Temp1).

No comments:

Post a Comment