| Requirements:
| - Assignments: Approx. 8 counting a total of 45%.
Assignments are due on the date specified. Late assignments will not be accepted.
- Two tests each counting 15 percent for a total of 30 percent;
- A final exam counting 15 percent;
- Attendance & Deportment: 10 percent.
-
All tests are cumulative.
-
Assignments will be graded on functionality (i.e., do they work),
structure and style. Structure includes clear and efficiently
written code. Style includes documentation, indentation
and overall readability. Documentation includes comments.
Programs without comments are unclear and unreadable.
- Please note that assignments count for 45% of the final
grade. The Even though I blew off half the assignments, I'll do well because I did well
on the tests theory is false.
- While much of the material is from the book, a significant
portion will be from the lectures. You are responsible for all
material presented in class. Consequently, attendance is required.
-
Assignment submissions:
-
Neatly printed and stapled. Clever edge and corner folding to
attach multiple pages will not be accepted nor will paper
clips.
-
Your name, the course, the date, the subject of the
assignment and the assignment number will appear in a comment
block at the beginning of each assignment. Non-complying
assignments will be returned ungraded.
- Assignments will not be accepted by email.
- No screen-caps unless graphic output is involved.
| Makeup Tests | Makeup tests will be given only in
cases of documented and demonstrated need for causes such as serious illness,
family emergency or University sanctioned schedule conflict.
Note: all makeup tests will be essay format.
| | Test dates:
|
- Test 1: TBA
- Test 2: Fri Nov 14
- Final: TBA
| Final Grades
|
Final grades will not be available via email. If you want your
grade mailed to you, bring a stamped, self-addressed envelope to the
final.
| | Originality
| If your work duplicates in whole or in part the work of someone
else, both works will receive a grade of 0.
If this occurs twice, a final grade of F will be assigned.
| | Classes
| Classes are lecture format. Cell phones, laptops, pagers and PDA's
may not be used. You are encouraged to bring your book to
class and take notes.
You are responsible for all material presented in class. If you elect
not to attend, you are responsible for obtaining the material
you missed. Email requests to me for summaries of material presented
in class will not be answered.
| |
Assignments
|
-
Do exercise 2.30 on page 61. Due Fri Sept 12.
-
Do exercise 5.27 on page 201. Ignore part C. Calculte the primes up to 1,000
instead of 10,000. Due: Fri Sept 26. Note: all primes are odd except 2.
-
Knowing the frequency of occurrence of letters in text is
the basis of decrypting programs as well as compression
algorithms.
In ASCII (see Appendix C), there are 128 characters numbered
0 to 127. Characters with numeric values between 32 and 126
are the printable characters, the rest are control characters
and do not print (such as linefeed, carriage-return, tab, etc.).
Each of the printable characters has a corresponding numeric
value. For example, the letter 'A' has the value 65, 'B' has the value
66 and so on. Blank (or space) has the value 32.
Write a program to read in several lines of text and
count the usage of each character except blank then print the
results.
To do this, make an array of int
of dimension 128. Initialize all elements to
zero.
In a loop, read characters from the input
using getchar() until the function
returns an EOF. When this happens,
end the loop and print the results.
There are examples in the book of using
getchar() with a while loop
until EOF.
The result of getchar() should be stored in
an int and this int variable used
to increment the corresponding element of the
128 element array.
When the input loop terminates, print out the
results. Write a for loop where the index variable
ranges from 33 to 126. In a printf()
print the value of the index variable using
a %c format which will cause its character
to appear, not its numeric values. On the same line
print the value of the array for this element.
Make the table look neat with appropriate
field width format controls.
To test your program, download some sample text to
your computer by typing the command:
wget http://www.cs.uni.edu/~okane/Virgil.html
This works on Linux and Cygwin as well as my servers
and should work with Apple Mac as well.
The text downloaded is 102 lines of Dryden's
translation of the Aeneid.
To test your program with this text, compile your
program so that it gives no errors then type:
Linux and Apple: ./a.out < Virgil.html
Cygwin: ./a < Virgil.html
The code "< Virgil.html" will cause the input to
be read from the file rather than the keyboard.
Output will display to the screen as usual.
Due Fri Oct 17. Note: Starting this Thursday Oct 16
will probably result in not getting it done in time.
-
Write a program to convert fully parenthesized
infix notation to suffix notation.
Fully parenthesized infix example:
((a+b)*(c/d))$
(the $ is an end marker)
The suffix for the above:
ab+cd/*
In suffix notation, the operator follows
the operands.
Your program:
- all operands will be single letters.
- a $ will indicate the end of the string.
- no embedded blanks.
Algorithm:
read a character from the input.
- if it is a $ you are done - see below.
- if it is a open paren, ignore it.
- if it is an operand, write it to the output.
- if it is an operator (+-*/), push it on a stack.
- if it is a close paren, pop the top of stack to output
use getchar() for input and putchar(int) for output.
the stack: an array with a corresponding index like:
char stack[20];
int stx = 0;
to push: put the character into stack[stx] then increment
stx.
to pop to output: decrement stx and putchar(stack[stx]);
when done, check to see that the stack is empty (stx==0).
if not, this is an error situation.
what does all this mean? suffix notation can be directly
executed by a computer whereas infix cannot. converting
input to suffix can be the first step to executing an
expression. some advanced calculators require you to
enter your expressions in suffix notation.
Due: Mon Oct 27.
program is about 15 lines long, more or less.
-
Write a program to read in an expression in suffix notation and
execute it.
Executing suffix: read a token from the input (a number or
an operator or a terminating $) then:
-
if the token is a number, push it on the stack
- if the token is an operator, pop the top two elements from the
stack, do the operation and push the result onto the
stack.
- if the token is a $, this means end of input. Print the
result which is on the stack.
If at the end there is more than one thing on the stack, this
is an error condition. If during execution of an operator you do
not have two things on the stack, this is also an error.
Dividing by zero is an error.
Simplifying assumptions: put a blank between each token and use
a scanf() to read each token in as a string (char array).
If the token is not a +, -, *, / or $, it must be a number.
Convert from string to numeric integer with the atoi() function.
The stack is an integer array.
Use the strcmp() function to compare the tokens read with
"+",. "-", "*", "/" and "$".
Due: Fri Nov 7.
| | Software
|
If you have a Microsoft based desktop or laptop and you want to
use it for assignments, you should install the free
package Cygwin. If you have an Apple, you should check to see that the
C/C++ development packages are installed.
If you are Linux based, install the C/C++ development packages
(these are usually omitted in a defaul install).
If you do not have or wish to use your own computer, accounts on a Linux server will be
available.
The book comes with a CD with the Microsoft Visual C++ compiler.
While this may be used, it is strongly recommended that you don't.
Instruction will assume you are using the Cygwin/Linux/Apple based
version of C/C++.
Note: basic BSD(Apple)/Linux/Cygwin commands will be covered in class.
You may also want to try installing Linux on your PC.
Your PC will then be a dual boot PC - you select which
operating system (Linux or Windows) when you start up.
Installation of Linux takes some expertise and
might not be suitable if you have limited experience.
Ubuntu seems to be the best option at present.
One option permits you to installi it into your Windows file system thus
not requiring a separate disk partition.
However, be sure you are backed-up before you fiddle with the operating system.
If you have an MS Windows based computer, you may want to install
Cygwin (Click Here)
The examples in class will be mainly with Cygwin and or Linux.
If you install Cygwin, be sure to install all packages as the
default installation does not include the development libraries
needed for compiling. Cygwin effectively lets you run
a Linux-like environment on your Windows machine.
If you are using an Apple Mac, there are compiler packages
available as well.
My Cygwin Install Notes
Note: last year Vista users had problems installing Cygwin
directly from the Internet. The install would 'hang' about
half way through. This was avoided by first
downloading the files to your machine and then installing
from these.
I have a server available on
which you can do your programming. To connect to it, you
will need putty and pscp installed on your Windows machine
or sch and scp on Apple Mac (they should be there already).
For windows users, google the term putty then download the
file putty.exe to your desktop. When you run putty,
use the address neamh.cns.uni.edu and be sure the ssh
box is checked. Use the login id and password you selected.
For Mac's, use a command prompt window and type
ssh yourid@neamh.cns.uni.edu where "yourid" is
replaced by your user id. It will prompt you
for your password.
-
Microsoft Visual C++ 2005 compiler click here
-
Cygwin for Windows
http://www.cygwin.com/
-
Cygwin Install Notes
| Topics:
|
- Overview of C/C++ programming languages
- Overview of compilers and editors available.
- Basic statements and sample programs
- Numbers and arithmetic operators
- Characters and character operations
- Operators and operator precedence
- Compound statements, multi-way decisions, jump statements
- Arrays
- Storage types
- Pointers and arrays
- Strings
- Constructed types: structures and dynamic allocation
- Objects
- Classes
- Vectors and matrices
- File systems
- Data structures
- Inheritance and polymorphism
- Multi-dimensional arrays
- Library Functions
| Cygwin for Windows |
http://www.cygwin.com/
Installation Notes for Windows
| | vi Editor
|
Introduction to display editing with VI
VI lovers home page
Mastering the VI editor
The VI/EX editor
VI Tutorial
| | | | |