CPSC 240 Assignment 4: Circumference of Circle solution

$30.00

Category:

Description

5/5 - (4 votes)

We start exploring floating point number by re-visiting the old circumference problem.   This time we don’t use the Ebyptian method but we the modern formula for the circumference of a circle of a given radius r.

General statement

Make a program that will accept as input a quadword float number representing the radius of a circle.  Compute the area of the circle with that radius.  The modern equation for the circumference is  c = 2 x π x r.  Use the modern value for π; you’ll have to look it up online.   That means you need to use the IEEE754 value for π.

Modular structure of the program

The C program circumference calls the X86 program (circle), but main does not pass any data to circle.  “main” calls “circle”. However, near the end of the execution, “circle” sends the computed value for circumference back to the driver, which out puts that value in IEEE754 format.

 

Your output will me mathematically correct to 19 decimal places.

Sample run

 

Welcome to your friendly circle circumference calculator.

The main program will now call the circle function.

This circle function is brought to you by William Bendix.

Please enter the radius of a circle as a floating point number: 2.75349664

The number 2.75349664 was received.

The circumference of a circle with this radius is 17.300729631816359 meters.

The circumference will be returned to the main program.  Please enjoy your circles.

The main received this number:  17.300729631816359 = 0x0x40314cfc9dfd96e2

Have a nice day.  Main will now return 0 to the operating system.

 

The text with yellow background is produced by the X86 function.  The text outside the yellow area is produced by the main function.  Often we refer to the main function as the “driver function”.  The driver function is not involved with the solution of the application problem, other than to simply call the function that does solve the problem.

 

When you create this program, replace the fake name shown above with your real name.

 

The file named run.sh is written in bash script language.  Its only purpose is to rapidly compile the two source files and run the program.

 

The word “program” refers to the collection of all 3 files.  Each of the individual files within the program may be called a “module” or a “function”.

 

The program (group of files) has a descriptive name.

What to do when you are done

 

Test the program with small integer inputs such as 3.0, 4.5, 8000.0,  -43.5,  0.0035

 

Try to break the program: try entering some unusual floats.

 

3.7      //Repeating IEEE hex number

 

0.9      //Ditto

 

775 000 000 000 000 000 000.1

 

4 000 000 000 . 000 000 000 73

 

When you send it me I will try to break it with extreme inputs.

 

 

 

 

This is extra credit assignment #4 out of 6.

 

This is an extra credit assignment.  The grading system was explained in the first or second class meeting of this semester.

 

When the program is functionally correct then make it a professional program.

 

Send all the files (3 of them) to me at the usual place:  holliday@fullerton.edu

 

Last day for credit: November 14

 

 

Assignment 5: last day for credit November 28

 

 

Assignment 6: last day for credit December 7 [Monday]