Code for calculating
square root without
using library function,
of math.h

Answers were Sorted based on User's Feedback



Code for calculating square root without using library function, of math.h..

Answer / sarath

#include<stdio.h>
#include<conio.h>

void main()
{
float i,num;
printf( "Enter number : ");
scanf("%f",&num);
for(i=2.0;i<num/2;i++)
{
if(num/i==i)
{
printf(" \nSquare root of %.0f = %.0f",num,i);
break;
}
else
continue;
}

if(num/i!=i)
printf("\nThere is no perfect integer square root for the number %.0f",num);
getch();
}

Is This Answer Correct ?    34 Yes 17 No

Code for calculating square root without using library function, of math.h..

Answer / manikant

#include<iostream.h>
void main()
{
int num,i;
cout<<"enter anumber:";
cin>>num;
for(i=2;i<num/2;i++)
{
if(num/i==i)
{
cout<<"\nsquareroot of "<<num<<"="<<i;
break;
}
else
continue;

}
if(num/i!=i)
cout<<"\nthis no is not a perfect square.";
}

Is This Answer Correct ?    16 Yes 13 No

Code for calculating square root without using library function, of math.h..

Answer / abhinav dwivedi

#include<stdio.h>
#include<conio.h>
void main()
{
int num,i;
clrscr();
printf("enter no to find square root");
scanf("%d",&num);
for(i=1;i<=num/2;i++)
{
if(num/i==i && num%i==0)
{
printf("square root of entered no is %d",i);
break;
}
else
{
continue;
}
}
if(num/i!=i)
printf("their is no perfect suare root of entered no");
}

Is This Answer Correct ?    10 Yes 9 No

Code for calculating square root without using library function, of math.h..

Answer / darshana

Dim i As Integer

Console.WriteLine("enter the number")
i = Console.ReadLine()

For a As Integer = 0 To 1000
If a * a = i Then
Console.WriteLine(a)
Exit Sub
End If


Next

Is This Answer Correct ?    5 Yes 14 No

Post New Answer

More C Interview Questions

What is a node in c?

0 Answers  


What are the uses of null pointers?

0 Answers  


What is unsigned int in c?

0 Answers  


What is scope and lifetime of a variable in c?

0 Answers  


Hi Every one......... Please Any body give me the answer for my question. Is it possible to print the word "PRINT F", without using printf() statement in C-Language.

4 Answers  






my name is nani i completed my b-tech in hyd now i want go for interveiw but i dont know the process of software field interveiws plz help me anyone how many rouds there n what rounds plz plz plz help me n where i can get these details

2 Answers  


What is the difference between null pointer and wild pointer?

0 Answers  


totally how much header files r in c language

8 Answers   TCS,


how to calculate the time complexity of a given algorithm? pls give exaples..mainly for the coplexities such as O(log n),O(n log n)...

1 Answers   Infosys,


if array a conatins 'n' elements and array b conatins 'n-1' elements.array b has all element which are present in array a but one element is missing in array b. find that element.

18 Answers   Parexel, Ram Infotech, Zycus Infotech,


Explain the array representation of a binary tree in C.

0 Answers   Genpact,


write a c program to convert fahrenheit to celsius?

4 Answers   TCS,


Categories