|
-
Apr 25th, 2002, 06:13 PM
#1
Code check please
I'm trying to make a prog that finds the area of a circle.
After asking the user the radius of the circle it should display the area after a calculation.
But the program wont display the final result. Why?
Code:
#include <iostream.h>
#include <conio.h>
int main()
{
int radius;
const double pi=3.14;
cout<<"Find the area of a circle!\n";
cout<<"Enter the radius of the circle you want to find the radius of(Works best with whole numbers): ";
cin>>radius;
cout<<"The area is: "<<(radius*pi);
getch();
return 0;
}
I'd appreciate if I could get help ASAP
-
Apr 25th, 2002, 06:31 PM
#2
Frenzied Member
PHP Code:
#include <iostream.h>
#include <conio.h>
int main()
{
int radius;
const double pi=3.14;
cout << "Find the area of a circle!" << endl;
cout << "Enter the radius of the circle you want to find the radius of(Works best with whole numbers): ";
cin>>radius;
cout << "The area is: "<< (radius*pi) << endl;
getch();
return 0;
}
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Apr 25th, 2002, 06:38 PM
#3
thx
-
Apr 25th, 2002, 06:48 PM
#4
Frenzied Member
Sure
Just remember to tell the iostream that you are done with a line from now on and you should be ok.
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Apr 25th, 2002, 08:53 PM
#5
-
Apr 26th, 2002, 09:47 AM
#6
endl does not only start a new line but also flushes the ouput buffer, so things are actually written to the screen.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Apr 26th, 2002, 11:24 AM
#7
Fanatic Member
Re: Code check please
Code:
cout<<"The area is: "<<(radius*pi);
The area of a circle is pi * r^2.
Digital-X-Treme
Contact me on MSN Messenger: [email protected]
[VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
/ (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]
-
Apr 26th, 2002, 03:13 PM
#8
oops
-
Apr 27th, 2002, 05:46 AM
#9
but in this case, you shouldn't do pi^2 but rather pi*pi (it's faster)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Apr 28th, 2002, 11:21 PM
#10
That would be pi*r*r right?
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Apr 29th, 2002, 02:11 AM
#11
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|