Member Avatar for kellnerq

Hi all,

I would like to ask you all for some help.
I need to write a program that allows me to have a circle radius as input and then print out the diameter, circumference and area of that circle.
Easy task but i have to put the calculations in the output statement. can you tell me where i went wrong please?
Here is what i have got so far.
Thanks for answers.

#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main()
{
const double PI = 3.14159;

double radius;

cout << "Please enter the radius: ";
cin >> radius;

double diameter;
double circumference;
double area;

cout << "The diameter is " <<double diameter = 2 * radius << endl; // have to write calculations in output statement
cout << "The circumference is " << double circumference = 2 * pi * radius << endl;
cout << "The area is " << double area = pi * radius * radius << endl;

return 0;

}

Delete lines 16, 17 and 18.

Delete everything to to the right = signs in the equations in lines 20, 21, 22 and put the = sign in the string identifying the operation that is being done.

cout << "The diameter is = " << 2 * radius << endl;

Member Avatar for kellnerq

thank you very much

the working sample is

#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main()

{
	const double pi = 3.14159;

		double radius;

	cout << "Please enter the radius. " << endl;
	cin >> radius;

	cout << "The diameter equals: " << 2 * radius << endl;
	cout << "The circumference equals: " << 2 * pi * radius << endl;
	cout << "The area equals: " << pi * radius * radius << endl;

	return 0;

}// end of program
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.