To find the given no. is perfect square (or) not
Program:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int m, n;
float p;
clrscr();
printf("Enter a number : ");
scanf("%d", &n);
p = sqrt(n);
m = p;
if (p == m)
printf("\n%d is a perfect square", n);
else
printf("\n%d is not a perfect square", n);
getch();
}
Output:
Case: 1
Enter a number : 81
81 is a perfect square
Case: 2
Enter a number : 12
12 is not a perfect square

CreatedOct 15, 2014

UpdatedDec 30, 2019

Views7,282
You May Like
Program to maintain employee details using structures
Program to maintain student details using structures
Check whether the person is eligible to vote or not
Print the numbers that are divisible by a given no.
Program to generate magic square
To sort the given numbers in ascending & descending order