Docsity

CS 1044 Summer II, 2000 Homework #3 - Prof. C. Knestrick, Assignments of Computer Science

Toggle sidebar
bg1
CS 1044 Summer II, 2000
Homework #3
Due: Friday, August 4 (by midnight)
All answers must be typed using either MS Word or an ASCII text editor and submitted
to the EAGS by midnight on Friday, August 4. There will be no late extensions for this
assignment. Handwritten answers will not be accepted; answers will not be accepted by
methods other than the EAGS (such as e-mail). All short answer questions ("describe,
"define", etc) can (and should) all be answered in one or two sentences. If you find
yourself needing to write more, it probably means that you have the wrong answer. For
any problem that involves computational steps, show intermediate work for partial credit.
The Honor Code is in effect for this assignment. You may consult your book, notes, or
the instructor/GTA, but NOT other students (regardless of if they are in the class or not).
By submitting this assignment you are pledging: "I have neither given nor received
unauthorized help on this assignment."
1) Write the C++ code to declare an array of integers of some constant size, MAX_SIZE.
Initialize each element in the array with the number of its index. For example, the first
slot in the array would get a 0, the second slot would get a 1, and so on.
2) What is the error in the following code, and what will be the result:
char Array[10];
Array[10] = โ€™\0โ€™;
3) Assume that X and Y are arrays of type int. Which of the following operations on
arrays are valid:
Assignment: X = Y;
Equality Test: X = = Y;
I/O: cout << X;
Arithmetic: X + Y;
Return: return (X);
Parameter: SomeFunction(X, Y);
pf2

Partial preview of the text

Download CS 1044 Summer II, 2000 Homework #3 - Prof. C. Knestrick and more Assignments Computer Science in PDF only on Docsity!

CS 1044 Summer II, 2000

Homework

Due: Friday, August 4 (by midnight)

All answers must be typed using either MS Word or an ASCII text editor and submitted to the EAGS by midnight on Friday, August 4. There will be no late extensions for this assignment. Handwritten answers will not be accepted; answers will not be accepted by methods other than the EAGS (such as e-mail). All short answer questions ("describe, "define", etc) can (and should) all be answered in one or two sentences. If you find yourself needing to write more, it probably means that you have the wrong answer. For any problem that involves computational steps, show intermediate work for partial credit.

The Honor Code is in effect for this assignment. You may consult your book, notes, or the instructor/GTA, but NOT other students (regardless of if they are in the class or not). By submitting this assignment you are pledging: "I have neither given nor received unauthorized help on this assignment."

  1. Write the C++ code to declare an array of integers of some constant size, MAX_SIZE. Initialize each element in the array with the number of its index. For example, the first slot in the array would get a 0, the second slot would get a 1, and so on.

  2. What is the error in the following code, and what will be the result:

char Array[10];

Array[10] = โ€™\0โ€™;

  1. Assume that X and Y are arrays of type int. Which of the following operations on arrays are valid:

Assignment: X = Y;

Equality Test: X = = Y;

I/O: cout << X;

Arithmetic: X + Y;

Return: return (X);

Parameter: SomeFunction(X, Y);

  1. What should the minimum size of the array be? Explain your answer.

char String1[SIZE] = "Hello World!";

  1. Assume an input filestream, inFile (it has been declared and opened) that contains a last name and a first name in the format Last^Firs^Middle (this is based on the HL message standard used in healthcare information systems). Write the C++ code to extract each name into itโ€™s own array. Then, combine the names into a single array in the form First MiddleInitial. Last (with spaces in between the names). Keep in mind that the input will contain the full middle name, but the output should only contain the first initial of the name, followed by a "." (period). You can assume a MAX_SIZE for all arrays of 256.