Click here to Skip to main content
15,922,419 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CALLBACK Pin
Rickard Andersson2013-Mar-04 14:17
Rickard Andersson2013-Mar-04 14:17 
GeneralRe: CALLBACK Pin
Shi Zhu13-Mar-04 1:15
Shi Zhu13-Mar-04 1:15 
GeneralRe: CALLBACK Pin
Gary R. Wheeler13-Mar-04 5:45
Gary R. Wheeler13-Mar-04 5:45 
GeneralRe: CALLBACK Pin
Shi Zhu13-Mar-04 15:07
Shi Zhu13-Mar-04 15:07 
GeneralCFormView MDI App. Pin
nimrodel12-Mar-04 17:41
nimrodel12-Mar-04 17:41 
GeneralRe: CFormView MDI App. Pin
Antti Keskinen13-Mar-04 23:05
Antti Keskinen13-Mar-04 23:05 
GeneralRe: CFormView MDI App. Pin
nimrodel14-Mar-04 21:39
nimrodel14-Mar-04 21:39 
Generalsquare-root project Pin
bishead12-Mar-04 17:12
bishead12-Mar-04 17:12 
I am trying to get this program to return a square-root value. The main function will call the Square_Root function that will use a do-while loop to calculated the SqRoot from the algorithm:

estimateSquareRoot = ((Number_Sent/estimateSquareRoot) +estimateSquareRoot)/2.0;

This statement will be placed in the loop that contunues to loop as long as
the square-root calculation is not within .00001 of the true value.


estimateSquareRoot*estimateSquareRoot-difference>=.00001

I can not get the loop to work. For example when I enter 9 it return 5, but
it should loop until it return the square-root of 3. If someone can point me
in the right direction please......Thank You


#include <iostream>
#include <math.h>
using namespace std;
double Square_Root (double); //declaring function returning double and passing a double



int main()
{

double Number_Enter, solution; //declaring two variables



cout<< "\n please enter a positive number."; //prompt
cin>>Number_Enter;

solution = Square_Root(Number_Enter);

cout<<"\n the square root of "<<number_enter<<"is" <<="" solution;

return="" 0;

="" }
=""
=""

double="" square_root(double="" number_sent)

{
="" double="" difference;
="" estimatesquareroot="1.0;
" do{
="" +="" estimatesquareroot)="" 2.0;
="" difference="estimateSquareRoot" *="" -="" number_sent;
="" }


while="" (estimatesquareroot*estimatesquareroot-difference="">=.00001);



return (estimateSquareRoot);
}
GeneralRe: square-root project Pin
greba12-Mar-04 17:59
greba12-Mar-04 17:59 
GeneralRe: square-root project Pin
Roger Wright12-Mar-04 18:39
professionalRoger Wright12-Mar-04 18:39 
GeneralAbout MSChart Pin
junli12-Mar-04 15:49
junli12-Mar-04 15:49 
GeneralUsing File Streams with an MFC app Pin
Blue Pyre12-Mar-04 13:11
Blue Pyre12-Mar-04 13:11 
GeneralRe: Using File Streams with an MFC app Pin
Michael Dunn12-Mar-04 15:01
sitebuilderMichael Dunn12-Mar-04 15:01 
GeneralRe: Using File Streams with an MFC app Pin
l a u r e n12-Mar-04 20:25
l a u r e n12-Mar-04 20:25 
GeneralRe: Using File Streams with an MFC app Pin
Blue Pyre12-Mar-04 22:52
Blue Pyre12-Mar-04 22:52 
GeneralRe: Using File Streams with an MFC app Pin
Antti Keskinen13-Mar-04 23:09
Antti Keskinen13-Mar-04 23:09 
GeneralFTP and Ident Server :: Winsock Pin
valikac12-Mar-04 10:14
valikac12-Mar-04 10:14 
GeneralRe: FTP and Ident Server :: Winsock Pin
Rob Groves12-Mar-04 11:23
Rob Groves12-Mar-04 11:23 
GeneralRe: FTP and Ident Server :: Winsock Pin
valikac12-Mar-04 12:43
valikac12-Mar-04 12:43 
GeneralSend Print Job Pin
Anonymous12-Mar-04 9:22
Anonymous12-Mar-04 9:22 
GeneralRe: Send Print Job Pin
Rob Groves12-Mar-04 11:32
Rob Groves12-Mar-04 11:32 
Generaledit boxes linking Pin
Oriented12-Mar-04 9:05
Oriented12-Mar-04 9:05 
Generaledit boxes linking Pin
Oriented12-Mar-04 9:02
Oriented12-Mar-04 9:02 
GeneralRe: edit boxes linking Pin
David Crow12-Mar-04 9:29
David Crow12-Mar-04 9:29 
GeneralRe: edit boxes linking Pin
John R. Shaw12-Mar-04 11:56
John R. Shaw12-Mar-04 11:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.