homework assignment 2

2
Lawrence Technological University Department of Mathematics and Computer Science MCS 1142 Introduction to C – Fall 2008 The second homework assignment is to write a program that will calculate the circumference and area of three circles. This program should display the output (which is to be printed to the console window) in the following format: Circle 1 radius: ##.## Circle 1 circumference: ###.## Circle 1 area: ###.## Circle 2 radius: ##.## Circle 2 circumference: ###.## Circle 2 area: ###.## Circle 3 radius: ##.## Circle 3 circumference: ###.## Circle 3 area: ###.## Don’t worry about formatting the numeric output but do your best to align the columns. We’ll work more with printf formatting later and we’ll be able to improve on this output. The three circles for which you should calculate circumference and output are circles with radius 5, 10, and 6.3 units. We don’t have to specify which units those are at this time. The formulas for circumference and area of a circle are listed below: circumference = 2 * pi * r area = pi * r 2 pi is not a provided but should be defined by you as a constant. Follow the example on Program 2-3 (pages 52 and 53) of the text book. Don’t forget the following program head for all programs submitted for grading. // Program Author: Your name // Student ID: xx000012345 // Email Address: [email protected] // Name of Program: Name of Program.c

Upload: rockondog0879739178

Post on 28-Jan-2016

213 views

Category:

Documents


0 download

DESCRIPTION

Homework Assignment 2

TRANSCRIPT

Page 1: Homework Assignment 2

Lawrence Technological UniversityDepartment of Mathematics and Computer Science

MCS 1142 Introduction to C – Fall 2008

The second homework assignment is to write a program that will calculate the circumference and area of three circles. This program should display the output (which is to be printed to the console window) in the following format:

Circle 1 radius: ##.##Circle 1 circumference: ###.##Circle 1 area: ###.##

Circle 2 radius: ##.##Circle 2 circumference: ###.##Circle 2 area: ###.##

Circle 3 radius: ##.##Circle 3 circumference: ###.##Circle 3 area: ###.##

Don’t worry about formatting the numeric output but do your best to align the columns. We’ll work more with printf formatting later and we’ll be able to improve on this output.

The three circles for which you should calculate circumference and output are circles with radius 5, 10, and 6.3 units. We don’t have to specify which units those are at this time.

The formulas for circumference and area of a circle are listed below:

circumference = 2 * pi * rarea = pi * r2

pi is not a provided but should be defined by you as a constant. Follow the example on Program 2-3 (pages 52 and 53) of the text book.

Don’t forget the following program head for all programs submitted for grading.

// Program Author: Your name// Student ID: xx000012345// Email Address: [email protected]// Name of Program: Name of Program.c// Program Due Date: MM-DD-YY// Objective: The Instructors description of the

programming assignment// Program Description: The Students description of how the program works// Honor Code: I have neither given nor received unauthorized aid in // completing this work, nor have I presented someone else's // work as my own!