810:051
Introduction to Computing
Fall 2008
MW 2:00-3:15; F 2:00-2:50

Instructor: Dr. O'Kane
Office: 318 ITT (East Gym)
e-mail: okane@cs.uni.edu
www http://www.cs.uni.edu/~okane
Tel 273-7322
Office Hours: Click Here
Purpose: Introduction to software development through algorithmic problem solving and procedural abstraction. Programming in the small (in C/C++). Fundamental control structures, data modeling, and file processing. Significant emphasis on program design and style.
Book: C How to Program, Fifth Edition by Harvey M. Deitel (Author), Paul J. Deitel (Author), Prentice Hall; 5th edition ISBN: 0-13-240416-8
Requirements:
  1. Assignments: Approx. 8 counting a total of 45%. Assignments are due on the date specified. Late assignments will not be accepted.
  2. Two tests each counting 15 percent for a total of 30 percent;
  3. A final exam counting 15 percent;
  4. 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
    1. Do exercise 2.30 on page 61. Due Fri Sept 12.

    2. 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.

    3. 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.

    4. 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.

    5. 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:

      1. if the token is a number, push it on the stack
      2. if the token is an operator, pop the top two elements from the stack, do the operation and push the result onto the stack.
      3. 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

    The following notice is required by the University:

    "The Americans with Disabilities Act of 1990 (ADA) provides protection from illegal discrimination for qualified individuals with disabilities. Students requesting instructional accommodations due to disabilities must arrange for such accommodation through the Office of Disability Services. The ODS is located at: 103 Student Health Center, and the phone number is: 273-2676."

    Because the Office of Disability Services has procedures in place to determine the validity of disability claims as well as the need for instructional accommodations, faculty are reminded that they are to direct all students with accommodation requests to the above listed office.

    UNDER NO CIRCUMSTANCE SHOULD A FACULTY MEMBER MAKE AN ACCOMMODATION INDEPENDENT OF THE OFFICE OF DISABILITY SERVICES.

    Questions may be directed to: Disability Services Coordinator, at 273-2676 or to this office at 273-2846.

    Kevin C. O'Kane / Computer Science Department / UNI / okane@cs.uni.edu

    Access count: