0% found this document useful (0 votes)
2 views

hw4_fall2011

This document outlines Homework Assignment No. 4 for the COMP2002 course at Sultan Qaboos University, due on December 24, 2011. Students are required to modify their previous program by implementing specific functions for handling arrays of x values and calculating their square roots. It also includes a grading rubric and policies regarding late submissions and academic integrity.

Uploaded by

lab67623
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

hw4_fall2011

This document outlines Homework Assignment No. 4 for the COMP2002 course at Sultan Qaboos University, due on December 24, 2011. Students are required to modify their previous program by implementing specific functions for handling arrays of x values and calculating their square roots. It also includes a grading rubric and policies regarding late submissions and academic integrity.

Uploaded by

lab67623
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Sultan Qaboos University

College of Science - Department of Computer Science


COMP2002: Introduction to Computer Programming for Engineers, Fall 2011
HOMEWORK ASSIGNMENT NO 4
Due Date: 24th December, 2011

 Your name, ID number, and section should be written as comments in your program.
 Name your program file HW4-ID.cpp replacing ID by your student ID number.
 Submit your program file on Moodle by the above deadline.

In this assignment you are asked to re-write your program of the previous assignment
(Homework 3) with the following modifications:

1. Declare inside the main function THREE one-dimensional arrays called


X_VALUES[], EXACT_SQRT[] and EST_SQRT[] and use them for storing the x
values, their exact square roots and their estimated square roots respectively.
2. Declare a global integer variable called size for storing the size of the three arrays
(i.e. the number of the x values).
3. Define and use in your program at least the following functions with suitable
parameters:
a. display_menu(): to display the menu options on the screen and read and
return the selected option (a character).
b. read_keyboard(): for reading x values from the keyboard (until CTL+z) and
store them in the X_VALUES[] array. This function must also set the value of
size to the number of x values read from the keyboard.
c. read_file(): for reading x values from an input file (until end of file) and
store them in the X_VALUES[] array. This function should start by asking the
user to enter the name of the input file. This function must also set the value of
size to the number of x values read from the input file.
d. generate_random(): for generating random x values and storing them in
the X_VALUES[] array. This function must start by asking the user to enter a
value for size (i.e. the number of x values to be randomly generated).
e. calculate(): for calculating the exact and estimated square roots of the x
values stored in X_VALUES[] and storing the results in the two arrays
EXACT_SQRT[] and EST_SQRT[]. This function must also return the
maximum difference between the calculated exact and estimated square roots.
f. display_results(): for writing the results in the output file and also
displaying them on the screen.

Page 1 of 2
Grading Sheet: COMP2002-Fall2002-HW4 0.0 0.25 0.5 0.75 1.0

1 Style (Comments, naming, indentation)

2 Includes, function prototypes and global declarations

3 Correctness of the main() function

4 Correctness of the display_menu() function

5 Correctness of the read_keyboard() function

6 Correctness of the read_file() function

7 Correctness of the generate_random() function

8 Correctness of the claculate() function

9 Correctness of the display_results() function

10 Program runs without compilation errors

LATE SUBMISSION AND COPYING PENALTY POLICY:

1. Late submission penalty: 50% per day.


2. Students involved in copying (e.g. copying in an exam, submitting similar or exact assignment solutions,
sharing Moodle class accounts) will be severely penalized. A zero mark will be given the first time a
student is caught involved in copying in any course item (e.g. Exam, Assignment) and his/her name will
be added to a watch list maintained by the Head of Department.
Further repeated involvement in copying will cause the student to get an F grade in that course. This is in
line with the university academic regulations. (See pages 36-37 of the 2005 edition of the university
academic regulations booklet).

Page 2 of 2

You might also like