WAP find square root of any number (without using sqrt() )?
Answers were Sorted based on User's Feedback
Answer / bhavya b
square of a no: n is the sum of first n odd no: for eg ..square of 7 is 1+3+5+7+9+11+13=49...
so we can find sqrt(m) by decrementing odd no:s from m upto m become 0 or less..then the no: of odd no:'s decremented will give the sqrt(m).
int sqroot(int m){
int n=0,i=1;
while(m>0){
m=m-i;
i+=2;
n++;
}
return(n);
}
| Is This Answer Correct ? | 6 Yes | 2 No |
Answer / akash dilwaria
#iclude<iostream.h>
#nclude<conio.h>
void main()
{
clrscr();
int n;
float sqrt;
cout<<"\n enter the number";
cin>>n;
sqrt=pow(n,0.5);
cout<<"\n square root of a number is="<<sqrt;
getch();
}
| Is This Answer Correct ? | 2 Yes | 3 No |
Answer / avinash
private int sqrt()
{
int n = console.readline();
n = n*n;
return n;
}
| Is This Answer Correct ? | 5 Yes | 11 No |
which is best institute to learn c,c++ in ameerpet hyderabad
What is ambiguity in c++
Can main method override?
What is overloading and its types?
What is object in oops?
What is the difference between pass by value,pass by pointer,pass by reference in the catch block in the exception handling in c++
What are the benefits of interface?
What does the code "cout<<(0==0);" print? 1) 0 2) 1 3) Compiler error: Lvalue required
What is function overloading and operator overloading?
What are constructors in oop?
WHAT IS THE ACTUAL DEFINATION OF OBJECT AND THE CLASS IN ONE SINGLE LINE WHICH THE INTERVIEWER WANT TO LISTEN.
write a program to find 2 power of a 5digit number with out using big int and exponent ?