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 / 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 |
Post New Answer View All Answers
Explain how can I remove the trailing spaces from a string?
how can f be used for both float and double arguments in printf? Are not they different types?
pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)
I have a varargs function which accepts a float parameter?
A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?
Why c is faster than c++?
what are the different storage classes in c?
What are the advantages of using new operator as compared to the function malloc ()?
How can I handle floating-point exceptions gracefully?
Why is #define used?
How would you use the functions fseek(), freed(), fwrite() and ftell()?
How main function is called in c?
List the difference between a 'copy constructor' and a 'assignment operator' in C?
There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?
How many types of operator or there in c?