write a subroutine to draw a circle x2 + y2 = r2 without making use of floating point computations at all..... i really dint get this question -.-
@infinity_
what does it mean "draw"? if it ise related to graphics i can't help.
i donno either.....i just copied the question from some random practise paper......i was wondering the same...
There are several explanations, but i can't start guessing...
ok i guess i l skip this 1 one nd save it for later :P hey can u check this give a c xpression to verify if a number is a power of 2....no loops are allowed
i thot this one cud be solved by recurssion....but they asked for an xpression
ok that's pretty easy.. do you have any ideas on how to solve it?
recurrsion? i m thinking
hmm.. by saying expression it means to solve it in constant time.. you have to take advantage of some properties.
ok ...lemme think
you can use mathematic functions such as logarithms and exponentiation right?
gosh i dint even think about it using log? i donno....never used log in c :-/
yeah i guess that's the only way
well consider a number k=2^n there is a property with this one 2^lgk=2^n which means that lgk=n.If lgk is an integer that means that k is a power of 2 so we are done, if it isn't integer this means that n is not integer which means that k is not a power of 2.That's what i am thinking.. lg is sort for log2
yea i got u.... but i m struck here like say how to verify if result is an integer in c? may be it jus casts the number to an integer
in c things get a bit complicated, but if you use some functions such as floor and the right variable types i think it will be ok.
yea may be jus print the result and check it for out self our use float nd multiply it by some 10000 :-/ may be i m missing some thing
ohk ther's floor function in c? thanks i got u :) use %f nd check their diff ==0?
I wrote the code and implemented my own log function.It's very convenient as you don't need to use any floats or any other functions. http://pastebin.com/2gRHpk9S take a look
thanks.....i shud say "NICE KNOWING YOU.... u r cool" :D
thank you :P If you want anything else, just ask :)
:D thanks
Join our real-time social learning platform and learn together with your friends!