From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot) Newsgroups: comp.os.msdos.djgpp Subject: Re: newbie math.h problem Date: 9 Jun 1997 19:15:37 GMT Organization: Oxford University, England Message-ID: <5nhkop$8dj@news.ox.ac.uk> References: <339A8355 DOT 4CF6 AT glasgow DOT prestel DOT co DOT uk> NNTP-Posting-Host: sable.ox.ac.uk Lines: 29 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Michael Johnson (mj AT glasgow DOT prestel DOT co DOT uk) wrote: : Hello and please take pity on a C newbie, : I've called the math.h lib and I get a SIGFPE error with what I think is : a stack dump? Any it will compile but not run. : Here's what I've got: : #include : #include : main() : { : double b; : printf("the square root of %d is %d\n",b,sqrt(b)); : } You might like to try giving b a value before using it, and also printing it as a floating point number rather than an integer. In addition it would be clearer to write `int main()' and to explicitly return a value before the end of the function. If you compile with -Wall and -O, the compiler will point all of these out to you. -- George Foot Merton College, Oxford