The 1 said:

Q-1

Can sm1 suggest a program to check whether a given no is perfect

square or not??

I'm not sure what you mean by "sm1" or "no" (in the context). I'm

guessing at "someone" and "number", but I'm not certain that my guesses

are correct.

The important thing about homework is to try doing it for yourself.

That's a vital part of the learning process.

To start you off:

The term "perfect square" suggests that this is an exercise in integers.

The highest value one can portably represent in a native unsigned

integer type is 4294967295, which is just a shade short of being a

perfect square itself. To be able to represent this, use unsigned long

int. The highest perfect square that can be portably represented in an

unsigned long int is 4294836225.

The lowest perfect square you can represent in an unsigned long int is 0

(or, if you don't count that, 1).

So you have lower and upper bounds on your problem.

Your next step is to capture a value from the user, and ensure it is

within the range 0 (or 1) to 4294836225. If it isn't, it might yet be a

perfect square, but not one that you can handle easily within the

context of a simple homework exercise, so you can reject it as being

outside the supported range.

Now you need to find the integer that is closest to the square root of

the number. You can find this via binary search.

Now multiply that number by itself. If it is equal to the input number,

the answer is "yes, this is a perfect square". Otherwise, the answer is

"no, this is not a perfect square".

Q-2

Also sm1 suggest a program to check whether a given no is perfect

power or not??

I suggest you finish Question 1 before attempting Question 2.

--

Richard Heathfield

"Usenet is a strange place" - dmr 29/7/1999

http://www.cpax.org.uk
email: rjh at the above domain, - www.