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() )?

Answers were Sorted based on User's Feedback



WAP find square root of any number (without using sqrt() )?..

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

WAP find square root of any number (without using sqrt() )?..

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

WAP find square root of any number (without using sqrt() )?..

Answer / avinash

private int sqrt()
{
int n = console.readline();

n = n*n;

return n;
}

Is This Answer Correct ?    5 Yes 11 No

Post New Answer

More OOPS Interview Questions

Why we use classes in oop?

0 Answers  


How do you achieve polymorphism?

0 Answers  


what is virtual function?

26 Answers   Aspire, HP, Infosys, RoboSoft, TCS,


all about pointers

2 Answers  


what is the difference between containership and inheritence?

1 Answers  


what uses of c++ language?

3 Answers  


What do you mean by public, private, protected and friendly?

3 Answers   CA,


class CTest { public: void someMethod() { int nCount = 0; cout << "This is some method --> " << nCount; } }; int main() { CTest *pctest; pctest->someMethod(); return 0; } It will executes the someMethod() and displays the value too. how is it possible with our creating memory for the class . i think iam not creating object for the class. Thanks in Advance... Prakash

0 Answers  


how can we design a magic square in c++?or suggest me the basic idea of it.

3 Answers  


What are the OOPS concepts?

106 Answers   A1 Technology, Bajaj, CTS, EDS, HP, Infosys, Intel, Microsoft, MNC, Persistent, PlanetSoft, ProConstructor, TCS, Virtusa, Wipro, YSoft Solutions,


What exactly is polymorphism?

0 Answers  


what is opps?why it is use in programming language?

2 Answers   Wipro,


Categories