Write a program which take a integer from user and tell
whether the given variable is squar of some number or not.
eg: is this number is 1,4,9,16... or not
Answer Posted / ruchi
#include<stdio.h>
#include<conio.h>
int main()
{
int num,p,flag=0,n=1;
printf("\nEnter the number ");
scanf("%d",&num);
p=num;
while(n<=num)
{
p=num/n;
n++;
if((p*p)==(num))
{
flag = 1;
break;
}
}
if(flag==1)
{
printf("\nThe number is the square of a number ");
}
else
{
printf("\nNumber is not square of any number ");
}
getch();
}
| Is This Answer Correct ? | 5 Yes | 5 No |
Post New Answer View All Answers
List the difference between a While & Do While loops?
What is const and volatile in c?
How can I call fortran?
Can we use visual studio for c?
What is c programing language?
How macro execution is faster than function ?
What type of function is main ()?
What is function prototype?
Write a program to reverse a given number in c?
what are bit fields? What is the use of bit fields in a structure declaration?
Why do we use stdio h and conio h?
What is malloc() function?
What does. int *x[](); means ?
How do I copy files?
What is difference between far and near pointers?