Saturday, August 18, 2018

VALID PERFECT SQUARE


  • Problem Description

    Get a positive integer. Let N be the number of test cases.Check the number whether perfect square or not.Print TRUE when the integer is perfect square.If it is not, return FALSE.Describe it without using built-in-function.Input format: The input is verified whether the number is perfect square or not. Output format: Whether the input is perfect square then true is returned, else it should return false. EXPLANATION: Get a non-negative integer from the user. Check it whether it is perfect square or not by using arithmetic functions. Print True when it is valid perfect square integer. If the integer is not valid perfect square integer, then print False. Note: Do not use any inbuilt function.
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
      int n,temp;
      scanf("%d",&n);
      temp=sqrt(n);
      if(temp*temp==n)
        printf("TRUE");
      else
        printf("FALSE");
    return 0;
    }
  • Test Case 1

    Input (stdin)
    34
    
    
    Expected Output
    FALSE
  • Test Case 2

    Input (stdin)
    121
    
    
    Expected Output
    TRUE

No comments:

Post a Comment