WAP find square root of any number (without using sqrt() )?
Answer Posted / 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 |
Post New Answer View All Answers
Can you inherit a private class?
What is an advantage of polymorphism?
What is the main purpose of inheritance law?
program for insertion ,deletion,sorting in double link list
write a program to find 2 power of a 5digit number with out using big int and exponent ?
What is polymorphism and types?
What is overloading and its types?
Are polymorphisms mutations?
What is polymorphism programming?
What is coupling in oops?
What does and I oop and sksksk mean?
What is oops in simple words?
Why is it so that we can have virtual constructors but we cannot have virtual destructors?
if i have same function with same number of argument but defined in different files. Now i am adding these two files in a third file and calling this function . which will get called and wht decide the precedence?
explain sub-type and sub class? atleast u have differ it into 4 points?