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 the Lvalue and Rvalue?

2 Answers  


DIFFERNCE BETWEEN THE C++ AND C LANGUAGE?

2 Answers   Wipro,


4.A function 'q' that accepts a pointer to a character as argument and returns a pointer to an array of integer can be declared as: A)int (*q(char*)) [] B)int *q(char*) [] C)int(*q)(char*) [] D)None of the Above

6 Answers   Accenture,


Explain the difference between #include "..." And #include <...> In c?

0 Answers  


What will be your course of action for a push operation?

0 Answers  






What type is sizeof?

0 Answers  


What are the rules for identifiers in c?

0 Answers  


the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters

0 Answers  


Describe the complexity of Binary search, Quicksort and various other sorting and searching techniques..

0 Answers   Huawei,


diff. between *p and **p

3 Answers  


what would be the output of the following prog? Justify your answer? main() { unsigned char ch; unsigned char i; ch = -255; printf("%d",ch); i = -1; printf("%d",i); }

1 Answers  


What is the best way to comment out a section of code that contains comments?

0 Answers  


Categories