write a program to input two unequal positive numbers and check whether they are perfect square numbers or not. If the user enters a negative number, then the program displays the message "Square root of a negative number can't be determined", Using switch statement
Answers
Answered by
0
#include <stdio.h>
#include <math.h>
int main() {
int i=2,y;
float x;
while(i--)
{
int a;
scanf("%d",&a);
switch(a>0)
{
case 1:
x=sqrt(a);
y=x;
if(x==y)
printf("%d is a perfect square.",a);
else
printf("%d is not a perfect square.",a);
break;
default:printf("Square root of a negative number can't be determined");
}
}
return 0;
}
Similar questions
Math,
1 month ago
World Languages,
2 months ago
Math,
2 months ago
Biology,
10 months ago
Hindi,
10 months ago