O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Programming Exercises

1:The factorial is an important mathematical function. The factorial of a number n is written n!. n! is calculated as the product of the integers from 1 to n. For example 4! = 4 × 3 × 2 × 1. Furthermore 1! = 1, and 0! = 1. Write a program that receives an integer from the user, calculates its factorial, and returns this value as output. Allow the user (through a loop construct) to perform as many calculations as he or she wants during one program. After each calculation, the program must ask the user whether he or she wants to perform another calculation.
2:Write a program that generates the following output:
*
**
***
****
*****
******
*******
********
3:Write a program that generates the following output:
 * ######## ** ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required