CISS-110 Project 2
This project deals with reading input from the user, storing the input into variables and displaying those variables. This program is an introductory project into the primitive data types int
, double
, and the string type.
Learning outcomes
- Build a program from the ground up.
- Using correct data types.
- Watching for lost precision in calculations.
- Interaction with C Compiler.
- Reviewing reported errors and deducing needed repairs.
- Successful compilation of project.
- Confirmation program produces desired results.
The following identifiers will be used:
int diameter, height;
double radius;
double circumference, areaOfCircle, cylVolume;
char name[40];
You will utilize the printf()
, fgets()
and scanf()
functions. You will also define a const
type double
whose value is 3.1415926 to be used for PI.
Prompt the user for their name and using the fgets()
function, read the name of the user. Once the name of the user has been read, greet the user. Proceed to get the diameter and height of some aluminum can (cylinder) using the scanf()
function.
Calculate the circumference of the base of the can, the area of the base (using the pow()
function), and the volume of the cylinder. Display the radius, diameter, circumference, area of the base, and volume of the cylinder.
Remember that the radius is half of the diameter. Circumference = PI * diameter Area of circle = PI * radius ^ 2 Volume of cylinder = Area of circle * height
Your output should resemble (user-provided values in bold-italic):
Enter your name: Bill Hello, Bill You have two more answers to provide. Enter the integer diameter of a cylinder: 5 Enter the integer height of the cylinder: 8 The radius is 2.500000. The diameter is 5. The height is 8. The circumference is 15.707963. The area of the base is 19.634954. The volume of the cylinder is 157.079630.
Submit the project into Blackboard as Project2_lastname.c.