C/C++ on Linux/Unix

Moderators: Lundin
Number of threads: 314
Number of posts: 633

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
pow(x,y) is not working Posted by krishnampkkm on 10 Dec 2009 at 10:12 PM
Hiii

I tried to write a small program in C.

#include<stdio.h>
#include<math.h>
int main()
{
printf("\n\n the 4^3 = %d",pow(4,3));
return 0;
}


And I compile like $gcc -lmath pgm1.c

but it doesn't work..What may be the reason.

Thanking you
Krish+
Report
Re: pow(x,y) is not working Posted by bowbe on 11 Dec 2009 at 9:45 PM
It compiles just fine without '-lmath'.
pow is expecting a return value of double, so you may want to change '%d' to something like '%.0f'. (testing it with %d showed 4^3=0)
Report
Re: pow(x,y) is not working Posted by ajitreen on 22 Feb 2011 at 2:02 AM
try this code I tried it using code blocks I use Ubuntu linux gcc4.4

include<stdio.h>
#include<math.h>

int main()
{
int a,b,c;

a=4;b=3;
c=pow(4,3);

printf("\n\n the 4^3 = %d",c);

return 0;

}

Report
Re: pow(x,y) is not working Posted by siva_developer on 29 Oct 2012 at 9:03 PM
its working fine in gcc , just check by compiling with gcc name.c and ./a.out
no need to use -lpm

Report
Re: pow(x,y) is not working Posted by ajitreen on 22 Feb 2011 at 2:09 AM
try this code I tried it using code blocks I use Ubuntu linux gcc4.4

include<stdio.h>
#include<math.h>

int main()
{
int a,b,c;

a=4;b=3;
c=pow(4,3);

printf("\n\n the 4^3 = %d",c);

return 0;

}




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.