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
Answers were Sorted based on User's Feedback
Answer / rj
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("\n give a number");
scanf("%d",&a);
for(b=1;b<a;b++)
{
if((a)==(b*b))
printf("\n the no is ");
//else
//printf("\n the no is not");
//break;
}
getch();
}
| Is This Answer Correct ? | 31 Yes | 6 No |
Answer / swapnil chhajer
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
int n;
printf("Enter the number : ");
scanf("%d",&n);
(n == (int)sqrt(n) * (int)sqrt(n)) ? printf("YES") :
printf("NO");
fflush(stdin);
getchar();
return 0;
}
| Is This Answer Correct ? | 6 Yes | 4 No |
Answer / 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 |
Answer / manvi
main()
{
int i,b,j;
printf("enter the no");
scanf("%d",&i);
for(j=1;j<i;j++)
{
b=j*j;
if(i==b)
{
printf("this no is squre of: %d",j);
return;
}
}
printf("not a square no");
}
| Is This Answer Correct ? | 1 Yes | 4 No |
Answer / satya
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
int r,n,s;
printf("Enter the number : ");
scanf("%d",&s);
n=sqrt(s);
r=n*n;
if(r==n)
printf("%d is a square of %d ",s,n);
else
printf("%d is not a square number",s);
| Is This Answer Correct ? | 0 Yes | 3 No |
Answer / vignesh1988i
#include<stdio.h>
#include<conio.h>
void main()
{
int m;
printf("enter the number other than 0 & negative's:");
scanf("%d",&m);
if(m<=0)
printf("%d is a invalid number",m);
else
{
for(int i=0;i<=m/2;i++)
{
if((i*i)==m)
{
printf("yes , %d is a square of a number %d",m,i*i);
break;
}
else
{
printf("it is not a square of any numbers ");
break;
}
}
getch();
}
thank u
| Is This Answer Correct ? | 12 Yes | 19 No |
Answer / vrushali
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main ()
{
int num = 0;
int sqr = 0;
while (1)
{
printf ("\n Enter the no for finding sqaure root ");
scanf ("%d",&num);
if (num==0)
break;
else
{
sqr = sqrt(num);
if (num/sqr == sqr)
printf ("\n Number's sqaure root %d",sqr);
else
break;
}
}
return 0;
}
~
| Is This Answer Correct ? | 1 Yes | 8 No |
Answer / a.ramachandiran b.sc cs
#include<stdio.h>
#include<conio.h>
void main()
{
int m,n,i;
clrscr();
printf("\nEnter a number : ");
scanf("%d",&n);
for(i=1;i<=n/2;i++)
{
if(n==(i*i))
m==1;
else
m==0;
}
if(m==1)
printf("\nGiven number is square of sum");
else
printf("\nGiven number is not square of sum");
getch();
}
| Is This Answer Correct ? | 3 Yes | 16 No |
Answer / rajesh kumar
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("\n give an integer value");
scanf("%d",&a);
if((a/(a/2))==(a/2))
printf("\n the variable is square of some no");
else
printf("\n the no is not square of some no");
getch();
}
| Is This Answer Correct ? | 2 Yes | 32 No |
how to print this sereis 2 4 3 6 5..........?
int a=2,b=3,c=4; printf("a=%d,b=%d\n",a,b,c); what is the o/p?
Are there namespaces in c?
Write a program to check armstrong number in c?
Which is best book for data structures in c?
Can you write a programmer for FACTORIAL using recursion?
write a program that will print %d in the output screen??
Do you know the difference between malloc() and calloc() function?
What is default value of global variable in c?
What are the various topologies? Which one is the most secure?
What is the difference between typedef struct and struct?
#include<stdio.h> main() { int a[3]; int *I; a[0]=100;a[1]=200;a[2]=300; I=a; Printf(“%d\n”, ++*I); Printf(“%d\n”, *++I); Printf(“%d\n”, (*I)--); Printf(“%d\n”, *I); } what is the o/p a. 101,200,200,199 b. 200,201,201,100 c. 101,200,199,199 d. 200,300,200,100