sqrt is a function that returns the square root of its parameter.

Since the printf shows 64.0, the correct line would be .... sqrt(x) ) ;

The cos function works the same way: it returns the cossine of the
parameter, so you have to use .... cos ( something );

Best regards!

Carlos

PS: yeah, the book has a mistake!!


On Wed, Oct 29, 2008 at 8:20 PM, Olufowobi Lawal <[EMAIL PROTECTED]> wrote:
> I had just started learning C and just joined the group.
>
> Presently I am reading the book "sams teach yourself C in 24hrs 2nd ed"
>
> The below source code is from page 151 of the book, I compiled it (using
> plato) but it gave me an error.
> I noticed that the sqrt function referred to nothing.
> But in the book it compiled successfully and the printed output was correct.
>
> so my question is; was the author mistaken & are there such similar errors
> in the book (for those who have read it before)?
>
> Or is my compiler the problem.
>
> Also is it possible to run C codes on Microsoft visual Studio C++
>
> #include<stdio.h>
> #include<math.h>
> main()
> {
> double x,y,z;
> x=64.0;
> y=3.0;
> z=0.5;
>
> printf("pow(64.0,3.0) returns: %7.0f\n",pow(x,y));
> printf("sqrt(64.0) returns: %2.0f\n",sqrt);
> printf("pow(64.0,0.5) returns: %2.0f\n",pow(x,z));
> return 0;
> }
>
>
> N.B
> There is something similar in pg 150 of the same book
> printf("The cosine of 45 is : %f.\n",cos);
>
> [Non-text portions of this message have been removed]
>
> 



-- 
=============================================
Carlos José de Almeida Pereira
Ilhéus - Bahia - Brasil

BLOG:
      http://starfightercarlao.blogspot.com
      http://starfightercarlaoenglish.blogspot.com (english version)

"Que o caminho seja brando aos teus pés;
 Que o vento sopre leve em teus ombros;
 Que o Sol brilhe cálido em tuas faces;
 Que as chuvas caiam serenas em teus campos.
 E, até que eu de novo te veja,
 que a Deusa te guarde na palma da mão! "
                     (Bênção Irlandesa adaptada)

Reply via email to