Homework 13: EOF
Name: _____________________________________________ Alpha: ___________________
Describe help received: ________________________________________________________
- Due before class on Friday, February 10
- This homework contains code to be submitted electronically.
Put your code in a folder called
hw13
and submit using the204sub
command. - This is a written homework - be sure to turn in a hard-copy
of your completed assignment before the deadline. Use the
codeprint
command to print out your code and turn that in as well.
Assignment
-
Circle one to indicate how you did for the reading assignment from
Homework 11 before class on Monday:
How carefully did you complete the reading? (Circle one)
Not at allSkimmed itRead someRead all -
Circle one to indicate how you did for the reading assignment from
Homework 12 before class on Wednesday:
How carefully did you complete the reading? (Circle one)
Not at allSkimmed itRead someRead all - Required reading for this homework: Section 5 (Odds & Ends) from the Unit 4 notes,
- Given the following code snippet:
double dog = 8.7; int bear = dog + 2; double* cat = &dog; dog += 3; bear += 4; *cat += 5;
Fill in the following table with the type and value of each expression after executing the code above.
expression type value dog
bear
*cat
XXX
Fill in the following table with the type only of each expression, and indicate "yes" or "no" whether each one is an "lvalue", meaning it could be used on the left-hand-side of an assignment statement.
expression type is lvalue? &bear
bear + dog
cat
*cat
*cat + 7
-
Write a program called
sum.c
that reads in the name of a text file, then reads that file and adds up all the numbers in that file, reporting their total sum tostdout
.For example, if
numbers.txt
consists of:1.1 15 23.7 6
then your program should run as:
Filename:
numbers.txt
45.8
Your program must not use
si204.h
; instead you should include only the standard header file<stdio.h>
.