BIOS 546 In-class programming exercises #1

 

 

1. Write a program that computes the circumference of a circle whose radius is 12.5.  The formula is: circumference = 2 * pi * radius ; use a value of 3.1416 for pi.  The expected answer is about 78.5.  Call this program "prog1_1.pl".

 

2. Copy the previous program into a new file called prog1_2.pl, then modify it so that it prompts the user for a radius, then returns the circumference.

 

3. Copy the previous program into a new file called prog1_3.pl, then modify it so it the user enters a number less than zero, the returned circumference will be 0 (and not a negative number).

 

4. Write a program called prog1_4.pl that prompts for and reads two numbers (on separate lines) and prints out the product of the two numbers multiplied together.

 

5. Write a program called prog1_5.pl that prompts for and reads a string (on one line), then a number (on another line), then prints out the string the number of times indicated by the number, with each copy on a separate line.  Have it print a maximum of 100 lines, then print an error message if the number given is greater than 100.