Hi,
This is my first post! I have been working my way through the tutorials here at www.cplusplus.com, and I have been using what I learn in each stage to create a small program.
I originally created a program that let the user enter a radius and then calculated the circumference and area of the circle, however I lost the original program.
I recreated the program, but the problem is that not all of the output was 'outputed', if you understand. I tried this twice and only this portion of the output appears on the console:
Hello! Please enter the radius of any circle: 5
The circumference of your circle is: 31.4 |
However, what I desire to be on the console is this:
Hello! Please enter the radius of any circle: 5
You entered a radius of: 5
The area of your circle is: 78.5
the circumference of your circle is: 31.4 |
**Please note, the user inputs the radius, I put in '5' as an example**
Below is the code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#include <iostream>
using namespace std;
#define PI 3.14
int main ()
{
double radius;
double area;
double circumference;
cout << "Hello! Please enter the radius of any circle: ";
cin >> radius;
cout << "\r";
cout << "You entered a radius of: ";
cout << radius;
area = PI * radius * radius;
circumference = 2 * PI * radius;
cout << "\r \r";
cout << "The area of your circle is: ";
cout << radius;
cout << "\r";
cout << "The circumference of your circle is: ";
cout << circumference;
return 0;
}
|
Thank you very, very much for reading and hopefully we can solve the problem! I'm sure I just did something stupid...
I am running windows 7 32bit and the compiler is Code::Blocks.
Thanks,
Top Hat