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

Can you inherit a private class?

1108


What is an advantage of polymorphism?

1098


What is the main purpose of inheritance law?

1200


program for insertion ,deletion,sorting in double link list

2696


write a program to find 2 power of a 5digit number with out using big int and exponent ?

2392


What is polymorphism and types?

1113


What is overloading and its types?

1184


Are polymorphisms mutations?

1170


What is polymorphism programming?

1139


What is coupling in oops?

1163


What does and I oop and sksksk mean?

1167


What is oops in simple words?

1110


Why is it so that we can have virtual constructors but we cannot have virtual destructors?

4960


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?

3541


explain sub-type and sub class? atleast u have differ it into 4 points?

2320