Make a simple program in c++ languaage that asks a user to enter a number from t
ID: 3665282 • Letter: M
Question
Make a simple program in c++ languaage that asks a user to enter a number from the keyboard (this number could have a fractional part). You should prompt the user to enter a value from the keyboard, so there is no confusion. Your program should then interpret this number as the radius of a circle and show both the area and circumference. In case you forgot here are the formulas:
• Area of circle: r2
• Circumference of circle: 2r
Example 1 (user input is underlined): Enter the radius of a circle: 3 Area: 28.2743 Circumference: 18.8496
Explanation / Answer
#include<iostream>
using namespace std;
int main()
{
//Declaring variables
const float PI = 3.14;
float radius;
double area;
double circumference;
cout << " C++ Program to Find Area of Circle and circumference" << endl;
cout << " Enter Radius : ";
cin >> radius;
area = PI * radius * radius;
circumference=2*PI*radius
cout << " Area of Circle = " << area << endl;
cout << " circumference of Circle = " << circumference << endl;
cin.ignore();
cin.get();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.