Q:

C program to check whether a number is Perfect Square or not

0

Write a C program to check whether a number is Perfect Square or not. Here’s simple C program to check whether a number is Perfect Square or not in C Programming Language.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Numbers in C

Normally, when we work with Numbers, we use primitive data types such as int, short, long, float and double, etc. The number data types, their possible values and number ranges have been explained while discussing C Data Types.

Here is source code of the C program to check whether a number is Perfect Square or not. The C program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.

SOURCE CODE : :

/* C program to check whether a number is Perfect Square or not  */

#include <stdio.h>
#include <math.h>

int main()
{
    int num;
    int iVar;
    float fVar;

    printf("\nEnter any number :: ");
    scanf("%d",&num);

    fVar=sqrt((double)num);
    iVar=fVar;

    if(iVar==fVar)
        printf("\nThe Entered Number [ %d ] is a Perfect Square.\n",num);
    else
        printf("\nThe Entered Number [ %d ] is not a Perfect Square.\n",num);

    return 0;
}

OUTPUT : :

/* C program to check whether a number is Perfect Square or not  */

Enter any number :: 1234

The Entered Number [ 1234 ] is not a Perfect Square.

Process returned 0

Above is the source code for C program to check whether a number is Perfect Square or not which is successfully compiled and run on Windows System.The Output of the program is shown above .

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Number Solved Programs – C Programming

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C program to find Sum of Series : 1+2+3+4+….+N u... >>
<< C program to Check whether a Number is Perfect Num...