Project5_S10

# Project5_S10 - procedure. Let the user enter the value n ....

This preview shows page 1. Sign up to view the full content.

Project 5: Chapter 8 Programming Problems (due Monday, April 19) 1. SetColor and WriteColorChar Create two procedure: (1) SetColor receives two byte parameters: forecolor and backcolor . It calls the SetTextColor procedure from the Irvine32 library. (2) WriteColorChar receives three byte parameters: char , forecolor , and backcolor . It displays a single character, using the color attributes specified in forecolor and backcolor. It calls the SetColor procedure, and it also calls WriteChar from the Irvine32 library. Both SetColor and WriteColorChar must contain declared parameters. Write a short test program that tests both procedures. Be sure to create PROTO declarations for SetColor and WriteColorChar. 2. Non-recursive Factorial Write a non-recursive factorial version of the Factorial procedure (section 8.3.2) that uses a loop. Write a short program that interactively tests your Factorial
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: procedure. Let the user enter the value n . If an overflow occurs in your loop when calculating each factorial value, your program should display an error message. If no overflow occurs, display the calculated factorial. Following is a sample of the interaction between the user and the program: Enter the value of n to calculate the factorial (-1 to quit): The factorial is: 1 Enter the value of n to calculate the factorial (-1 to quit): 1 The factorial is: 1 Enter the value of n to calculate the factorial (-1 to quit): 5 The factorial is: 120 Enter the value of n to calculate the factorial (-1 to quit): 12 The factorial is: 479001600 Enter the value of n to calculate the factorial (-1 to quit): 13 Error: Calculated value cannot fit into 32 bits Enter the value of n to calculate the factorial (-1 to quit): -1...
View Full Document

## This note was uploaded on 09/08/2010 for the course CMPE 46 at San Jose State University .

Ask a homework question - tutors are online