Search code examples
visual-foxproperfect-square

Write a program in Visual Foxpro to check a number for perfect square


Ask the user to input a number. Check whether the entered number is a perfect square. I tried. enter image description here


Solution

  • local num, nSqrt
    Input "Enter a number" to num
    IF m.num > 0 
      nSqrt = SQRT(m.num)
      IF m.nSqrt == INT(m.nSqrt)
        ? LTRIM(STR(m.num)) + ' is a perfect square'
      ENDIF
    endif