0% found this document useful (0 votes)
18 views

Cs How To Start Programming

This C++ program asks the user to input the radius of a circle and then calculates and outputs the area, circumference, and diameter of the circle using the appropriate formulas. It includes the necessary header files, declares and initializes the variables, prompts the user for input, performs the calculations, and prints the results.

Uploaded by

rivespi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Cs How To Start Programming

This C++ program asks the user to input the radius of a circle and then calculates and outputs the area, circumference, and diameter of the circle using the appropriate formulas. It includes the necessary header files, declares and initializes the variables, prompts the user for input, performs the calculations, and prints the results.

Uploaded by

rivespi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

// Input the radius of a circle, and output the area.

#include <iostream> #include <string> using namespace std; int main () { pounds, kg; cout << "what is your name (first name only)?"; cin >> name; cout << "how many pounds do you weigh? "; cin >> pounds; kg = pounds / 2.205; cout << name <<", you weigh" << kg << "kilograms." <<endl; }

// Input the radius of a circle, and output the area. #include <iostream> using namespace std; #include <string> int main () { double pi, radius, area, circumference, diameter; pi = 3.1415926535897; cout << "Please input the value of the diameter: "; cin >> diameter; radius = diameter/2.; area = pi * (radius*radius); circumference = 2 * pi * radius; cout << "The area of the circle is " << area << " and the circumference is " << circumference << '.' << endl; }

3.141592387

Hw 1d
#include <iostream> using namespace std; int main () { cout << "This program will determine the area, cirfumference and radius of a circle" <<endl; return 0; } const double PI = 3.14159; double radius; double circumference; cout << "Please enter the radius: "; cin >> radius; double diameter = // use the formula for calculating the diameter. sqrt circumference = // use the formula for calculating the circumference. double area = // use the formula for calculating the area. cout << "The diameter is " <<endl; cout << "The circumference is " <<endl; cout << "The area is " <<endl;

You might also like