C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28691
Number of posts: 94711

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

Report
WHat will this code produce? Posted by Panasonic99 on 5 Aug 2005 at 7:05 PM
#include <stdio.h>
#include <math.h>

void main()
{
int i = 25, j = 2, k = 5;
printf("%.2f\n", sqrt(i));
printf("%.2f\n", pow(j,k));

}



it aint working for me
Report
Re: WHat will this code produce? Posted by bell2 on 5 Aug 2005 at 7:41 PM
Well, if you change the code around a bit:
#include <stdio.h>
#include <math.h>

int main() /* If you compiled with a C++ compiler you must change main()'s return type to 'int'. */
{
int i = 25, j = 2, k = 5;
printf("%.2f\n", sqrt(i));
printf("%.2f\n", pow(j,k));

/* Get some input, so the program stays running long enough to read the output. */
int extra;
scanf("32%s", extra);
}

...You get this for output:
5.00
32.00


Report
Re: WHat will this code produce? Posted by Panasonic99 on 5 Aug 2005 at 7:50 PM
how?
Report
Re: WHat will this code produce? Posted by stober on 6 Aug 2005 at 4:00 AM
: how?
:
you been watching some old John Wayne westerns? How what???

Report
Re: WHat will this code produce? Posted by Donotalo on 5 Aug 2005 at 10:47 PM
: #include <stdio.h>
: #include <math.h>
:
: void main()
: {
: int i = 25, j = 2, k = 5;
: printf("%.2f\n", sqrt(i));
: printf("%.2f\n", pow(j,k));
:
: }
:
:
:
: it aint working for me

the code is clearly fine and obviously produce some valid output as i expected. why dont u check with a compiler rather than asking us? what is ur expectation from the code? be more specific.



 

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.