Privacy and Security Notice

Archived Messages for C_CLASS98@cebaf.gov: Next Assignment

Next Assignment

Dr. C. Allen Butler (allen@va.wagner.com)
Thu, 12 Mar 1998 07:23:00 -0800 (PST)

# Chapter Review Problems Problem to Submit Due Date
-- ------- -------------- ----------------- -------
1. 4 None 26 03/03/98
2. 2 19 - 24 24 03/05/98
3. 3 1,3,5,22,23,25 3 03/12/98
4. 4 13,22,23,29,31 see below 03/19/98
(cont) 5 5,15,17,26 see below

Assignment 4 Due Date: 3/19/98

Write a program that will read a list of strings from a file. The name
of the file is "numbers". Each line of the file is supposed to contain
a single number. Your program must determine if the string is an
integer, a float or neither. The first line of the file will contain an
integer which indicates the number of subsequent data lines in the
file. After the program converts the string to an integer or float
print the number out. If you find an error in the string, print the
string and an error message. For example, if the input file "numbers"
consists of:
5
32.87
-23
16.24.5
30+2
45k

Then your program should produce the following output:
Processing 5 numbers.
32.87 is a float.
-23 is an integer.
"16.24.5" is not a valid integer or float.
"30+2" is not a valid integer or float.
"45k" is not a valid integer or float.

Notes: You may assume the first line of the file is always valid and
correct. Use getc() to read in the strings. You must write your own
conversion routines -- do not use the standard library. Use printf()
for your output and use numeric formats for the valid numbers.
You may choose to handle scientific notation as valid or not. Please
indicate your choice in your header.