Lab 2: Variables - PowerPoint PPT Presentation

1 / 5
About This Presentation
Title:

Lab 2: Variables

Description:

Design a program to compute the area and circumference of a circle. The user will input: ... cout 'The circumference is ' circ endl; return (0) ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 6
Provided by: jimand
Category:

less

Transcript and Presenter's Notes

Title: Lab 2: Variables


1
Lab 2 Variables Equations
  • Design a program to compute the area and
    circumference of a circle.
  • The user will input
  • Radius of the circle (in meters)
  • A name for the circle (string of less than 50
    characters)
  • The program will output to the console
  • Name of your circle
  • The area and circumference of the circle
  • Use ALL the following concepts
  • Style (comments, variable names, etc.)
  • Named Constants (for pi)
  • Reading a string
  • The pow function
  • Hand-in the following
  • IPO Chart
  • Flow Chart with Pseudocode
  • Enter and test your algorithm using the compiler
  • Demonstrate that your program is working before
    leaving.

2
IPO Chart
3
Flow Chart and Pseudocode
Start
Enter Name and radius
Area radius2 3.14
Perimeter 2radius3.14
Display name, Area, and Circ.
Stop
4
Desk Check Chart
5
Code
  • /
  • Author Jim Anderson
  • /
  • include ltiostream.hgt
  • include ltmath.hgt
  • int main ()
  • char name50
  • double radius
  • double diameter
  • double circ
  • double area
  • const double pie 3.14159
  • cout ltlt "Enter the name of your circle "
  • cin.getline(name,50)
  • cout ltlt "Enter the radius (meters) "
Write a Comment
User Comments (0)
About PowerShow.com