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



Write a program which take a integer from user and tell whether the given variable is squar of som..

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

Write a program which take a integer from user and tell whether the given variable is squar of som..

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

Write a program which take a integer from user and tell whether the given variable is squar of som..

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

Write a program which take a integer from user and tell whether the given variable is squar of som..

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

Write a program which take a integer from user and tell whether the given variable is squar of som..

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

Write a program which take a integer from user and tell whether the given variable is squar of som..

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

Write a program which take a integer from user and tell whether the given variable is squar of som..

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

Write a program which take a integer from user and tell whether the given variable is squar of som..

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

Write a program which take a integer from user and tell whether the given variable is squar of som..

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

Post New Answer

More C Interview Questions

What is structure padding and packing in c?

0 Answers  


what is pointer ?

10 Answers   Kernex Micro Systems,


How do you convert strings to numbers in C?

0 Answers  


what is the difference between : func (int list[], ...) or func (int *list , ....) - what is the difference if list is an array and if also if list is a pointer

2 Answers  


A B C D E F G F E D C B A A B C D E F F E D C B A A B C D E E D C B A A B C D D C B A A B C C B A A B B A A A

2 Answers  






what are the languages used in c#?

3 Answers   Infosys,


What should malloc() do? Return a null pointer or a pointer to 0 bytes?

0 Answers  


Explain what is the advantage of a random access file?

0 Answers  


what is the use of macro program

1 Answers   TCS,


a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above

0 Answers  


what is the use of getch() function in C program.. difference b/w getch() and getche()??

29 Answers   HCL, IBM, Infosys, TCS, Wipro,


Write a program to print a (*)pattern programming (A to Z) in capital in one programming ?

2 Answers   TCS,


Categories