Problem:
To find whether the given no is perfect square or not . this so simple to find int and float float value of square root no is same if and only if that no is perfect square, example int sqrt of 2 is 1 and that of float is 1.414,
Solution:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int s1,no;
float s2;
clrscr();
printf("\n enter the no ");
scanf("%d",&no);
s1=sqrt(no);
s2=sqrt(no);
if(s1==s2)
printf("\n the given no %d is square",no);
else
printf("\n the given no %d is not square",no);
getch():
}
Output:
To find whether the given no is perfect square or not . this so simple to find int and float float value of square root no is same if and only if that no is perfect square, example int sqrt of 2 is 1 and that of float is 1.414,
Solution:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int s1,no;
float s2;
clrscr();
printf("\n enter the no ");
scanf("%d",&no);
s1=sqrt(no);
s2=sqrt(no);
if(s1==s2)
printf("\n the given no %d is square",no);
else
printf("\n the given no %d is not square",no);
getch():
}
Output:
No comments:
Post a Comment