Homework #1

Due: Wednesday, September 30

  1. [20 points]

    Write a program that produces the following output:

    Welcome to the world
    of "C".

  2. [20 points]:

    Identify the invalid variable declarations. For each invalid declaration, indicate the reason it is invalid.

    a.  int hw#1;  
    b.  float stock1, STOCK1;
    c.  int temp1;
        float temp1;
    d.  float microsoft_stock_price_to_earning_ratio;

  3. [20 points]:

    Assuming the following variable declarations:

    int a=20;
    int b=80;
    int c=40;
    What is the output of the following statements:
    a.	printf ("Evaluation:  %d\n", a+b/c);
    b.	printf ("Evaluation:  %d\n", (a+b)/c);
    c.	printf ("Evaluation:  %d\n", (a+b)%c);
    d.	printf ("Evaluation:  %.2f\n", (a+b)/(float)c);

  4. [40 points] Write a program that calculates a student's grade, based on three homework grades. First, prompt the user for three grades. Then calculate the average (using two decimal points.) If the average is greater than 90.0 display the words, "Great!". Otherwise, display the words, "Keep Studying..." Example output is provided below:
    Enter grade #1:  90
    Enter grade #2:  45
    Enter grade #3:  67
    Student Average:  67.33
    Keep studying...