CSE 271: Homework 2

Assigned: 21 January
Due: 25 January

  1. Which of the following are invalid variable names? Why? (Put your answers in a file called hw2.txt.)
    1. Int
    2. Printf
    3. floating
    4. ReInitialize
    5. char
    6. Xx
    7. _1312
    8. _
    9. 6_05
    10. alpha-beta-count
    11. A$
    12. $B

  2. Write a program in C (called poly.c) to evaluate the polynomial: 4x3 - 5x2 + 9
    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 (called factorial10.c) that generates the appropriate output (similar to that above), when looping through the first 10 factorials (e.g., 1!, 2!, ... 10!)..

Submission Requirements

  1. All three files must reside in the cse271.131/hw2 subdirectory. You will receive an email after your assignment has been collected.

Last revised: 17 January 2013.