CSE 271: Homework 2

Assigned: 26 January 2007
Due: 31 January 2007, in class, on paper.

  1. Which of the following are invalid variable names? Why?
    1. Int
    2. Printf
    3. floating
    4. ReInitialize
    5. char
    6. Xx
    7. _1312
    8. _
    9. 6_05
    10. alpha-beta-routine
    11. A$
    12. $B

  2. Write a program to evaluate the polynomial: 2x3 - 5x2 + 6
    for any value of x, which should be of type float.

  3. The factorial of an integer n, written n!, is the product of the consecutive integegers 1 through n. For example, 5 factorial is calculated as
    5! = 5 x 4 x 3 x 2 x 1 = 120
    Write a program that generates the appropriate output (similar to that above), when looping through the first 10 factorials.


Last revised: 23 January 2007.