Page 2 of 2

Re: 11461 - Square Numbers

Posted: Tue Jul 15, 2014 11:48 pm
by lighted
Third way is close to correct answer.
The problem description:
Given two numbers a and b you will have to find out how many square numbers are there between a and b (inclusive).
Change line

Code: Select all

 if(i==sqrt(i)*sqrt(i))
                coun++;
It is better to work only with integers. sqrt returns double value. :)

Code: Select all

int j = sqrt(i);
if(i==j*j)
      coun++;