Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Why is oop better than procedural?

1021


What is inheritance in simple words?

1009


What is object and example?

1112


Can private class be inherited?

1116


What does <> mean pseudocode?

1111


what is different between oops and c++

2455


What are the 4 main oop principles?

1160


What is polymorphism in oop example?

959


Why is object oriented programming so hard?

1022


Why do we need oop?

1103


Describe these concepts: Polymorphism, Inheritance and Abstraction.

1138


What is overloading and its types?

1078


What are different oops concepts?

999


What is the difference between a constructor and a destructor?

1171


What is encapsulation in oops?

955