You are here:

C++/how to calculate perfect Squares

Advertisement


Question
Madam my Question is like that i had numbers from 1 to 10000 and i have to take  only those numbers which are perfect Squares like 4,16,25,36,49,64,81

Answer
for( int i =2;i<=1000;i++)
 {
      for( int j =2;j<= i;j++)
      {
         if( (i%j) == 0)
         {
         if( i == (j*j))
         {
         cout<<"the square is"<< i;
         
         }
         }
      }
 }

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


rakshitha

Expertise

Difficult questions related to C .

Experience

C ,vc ,opc ,windows CE, ActiveX

Education/Credentials
Masters in electrical engineering

©2016 About.com. All rights reserved.