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


Please Help Members By Posting Answers For Below Questions

What is n in c?

563


Do pointers take up memory?

641


Why do we need arrays in c?

569


What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?

798


Why is c called "mother" language?

845






Suppose we have a table name EMP as below. We want to perform a operation in which, I want to change name ‘SMITH’ from as ‘SMITH JAIN’. Also I want to change the name of the column from ENAME to E_NAME. EMPNO ENAME JOB MGR HIREDATE SAL 7369 SMITH Coder 7902 17-DEC-80 800 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 7521 WARD SALESMAN 7698 22-FEB-81 1250

1491


How many levels deep can include files be nested?

638


What is #line used for?

566


Is multithreading possible in c?

555


p*=(++q)++*--p when p=q=1 while(q<=6)

1258


How can I change the size of the dynamically allocated array?

614


What is the purpose of main( ) in c language?

606


What are lookup tables in c?

538


if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.

4480


What is optimization in c?

556