Escolar Documentos
Profissional Documentos
Cultura Documentos
COURSE SYLLABUS
C PROGRAMMING COS-116-GS
Course Syllabus C PROGRAMMING COS-116-GS Thomas Edison State College June 2009
Course Essentials
C Programming offers an introduction to programming using structured techniques that cover the C language. The course includes discussions of algorithms, data types, arithmetic, assignments, relation, and repetition. Functions, arrays, pointers, character strings, structures, and files are used. After successfully completing this course, you will understand how to write computer programs using ANSI C language.
Objectives
Upon completion of the course, you should be able to: Perform arithmetic and character operations. Include selection. Include repetition. Include functions. Manipulate arrays using pointers. Handle a variety of structures. Manipulate files.
Course Materials
In addition to the Course Syllabus, you will need the following materials to do the work of this course. The textbook is available from the textbook supplier, MBS Direct.
Textbook
A First Book of ANSI C, 4th ed., by Gary J. Bronson (Boston: Thomson Course Technology, 2007).
Hardware/Software Requirements
Regular access to a computer with C compiler software--either on a Windows or MS-DOS computer or on a Macintosh with PC emulation or with SoftPC installed. A C compiler is not supplied by the College and
S-3
must be acquired by the student prior to or at the start of the course. It is not possible to proceed through the course without a C compiler. The compiler should be a full implementation of the ANSI standard for C. An ANSI C++ compiler may be used because C is a supported subset in a C++ compiler. Complete documentation is required to handle compiler variants and operational problems. If you still have questions about the compiler you are planning to use, please check with your mentor. Regardless of the compiler you use, you must take responsibility for compiler support.
Course Structure
C Programming is a three-credit, 12-week course consisting of ten study assignments, ten written assignments, and two examinations. Study assignments involve textbook readings. Periodically, you will complete a written assignment and send it to your mentor for correction and grading. In addition, the course requires you to take two examinations, a midterm and a final. See the "Course Calendar" for the study assignments and for the dates for submitting written assignments and scheduling your examinations.
Written Assignments
The ten written assignments in the course are built around associated textbook chapters. Assignments 18 require that you choose one of two problems to complete. Assignments 9 and 10 each have an A and a B section. For these two assignments, you should select one problem from the A section and one problem from the B section. Take the time to familiarize yourself with the Written Assignments section of the syllabus, and read through the assignment questions before you begin each lesson. Please take particular note the specific preparation requirements that are given there. In addition, check the Student Handbook section of the Course Manual to learn about procedures for preparing and submitting assignments. See the "Course Calendar" for the dates for submitting written assignments.
Examinations
You are required to take two examinations, a midterm and a final. See the Course Calendar for the scheduling of these examinations. Refer to the Student Handbook for information on all exam policies and procedures.
S-4
Both the midterm and the final exam are two hours long. They are openbook and open-notes exams. Both exams require that you write a different C program for each question.
Midterm Examination
The midterm will cover the material in textbook Chapters 17. You may take the examination only during the designated exam week, at an approved location, and with an approved proctor. During the first week of the semester you must submit a Proctor Request Form with the necessary documentation to the Office of Test Administration.
Final Examination
The final examination will cover textbook Chapters 814. The final exam is taken online in Blackboard. An exam link will be activated and made available to you in the Exams>Final Examination area of the course Web site at the start of final exam week. You may take the exam at any time during that week, but no later than midnight Saturday (eastern time). If you are on a course extension, you will need to arrange with your mentor a time to reschedule the final exam.
Grading
Your final grade will be determined by your performance on the two exams and the ten written assignments. In determining a final grade, your mentor will take into account patterns of improvement during the semester. Your final grade in the course will be determined as follows: Written Assignments Midterm Exam Final Exam 50% 30% 20%
Letter grades for assignments and examinations equate to numerical grades as follows: A A B+ B B = = = = = 93100 9092 8889 8387 8082 C+ C C D F = = = = = 7879 7377 7072 6069 Below 60
To receive credit for the course, you must earn a letter grade of D or higher on the weighted average of all assigned course work (e.g., exams,
S-5
assignments, projects, papers, etc.). You will receive a score of 0 for any work not submitted.
S-6
Course Calendar
Using the Week-by-Week Dates in the General Course Instructions section of the Course Manual, write the dates for the current semester in the second column. In the last column, fill in the dates for sending assignments and taking the examinations. All written assignments are to be submitted by Sunday of the week they are due.
Week
Date
Textbook Readings
Written Assignment
1 2 3 4 5 6
1 2 3 4 5 6, 7
Written Assignment 1 Written Assignment 2 Written Assignment 3 Written Assignment 4 Written Assignment 5 Written Assignment 6
S-7
Week
Date
Textbook Readings
Written Assignment
9 10 11
11 9, 12, 13 10, 14
12
S-8
Written Assignments
There are ten assignments. Assignments 18 require that you choose one of two problems to complete. Assignments 9 and 10 each have an A and a B section. For these two assignments, you should select one problem from the A section and one problem from the B section. Be sure to check your "Course Calendar" for when to submit each assignment to your mentor. Identify clearly which items you are answering. Include your name and assignment number at the top of every program in comments. Be sure that your answers to the assignment questions are well developed and convey your understanding of the course materials. You need to show that you have a fundamental grasp of the material by sending in the most complete answers possible. Be sure to check with your mentor for the format in which Written Assignments are to be delivered. Many mentors want .c source code files submitted directly from your compiler. Submit your assignments according to the instructions in the Student Handbook section of the Course Manual.
Assignment 1 (Chapter 1)
Choose one problem from the following: 1. Write an algorithm describing the steps you would use to analyze this polynomial: 3x3 5x2 + 6 Test the algorithm by giving x a value of 2. Do not code this problem in C. Instead, deliver the algorithm to solve the problem. 2. Consider the following programming problem: The formula for the standard normal deviate Z, used in statistical applications, is:
where refers to a mean value and to a standard deviation. Using this formula, write a program that calculates and displays the value of the standard deviate when X = 85.3, = 80, and = 4. (Zed Z; mu ; sigma ) Determine an algorithm for converting the input items into output items. S-9
Do not code this problem in C. Instead, deliver the algorithm to solve the problem.
Assignment 2 (Chapter 2)
Choose one problem from the following: 1. Write a C program that stores the integer value 5 in the variable save1 and the integer value 2 in the variable save2. (Make sure to declare the variables as integers.) Have your program calculate the total of these numbers and their average. The total should be stored in the variable named total and the average in the variable named average. (Use the statement average = total/2.0; to calculate the average.) Use the printf() function to display the total and average. 2. Write a C program that stores the number 123.45 in the variable alpha, 98.76 in the variable beta, and 76.67 in the variable gamma. (Make sure to declare the variables first as either float or double.) Have your program calculate the total of the three numbers and their average. The total should be stored in the variable total and the average in the variable average. (Use the statement average = total/3.0; to calculate the average.) Use the printf() function to display the total and average.
Assignment 3 (Chapter 3)
Choose one problem from the following: 1. Ask the user to enter a digit between 0 and 9. Have the program print out the digit in words, for example: Enter a digit between 0 and 9: 4 You entered the number four Assume that the user will enter only a single digit. The user may accidentally enter a single character, and this should generate an error message. 2. If you choose to answer problem 2 in Written Assignment 3, you must complete both parts a and b. a. Write a C program that displays the following prompts:
S-10
After each prompt is displayed, your program should use a scanf() function call to accept a number from the keyboard for the displayed prompt. After the third number has been entered, your program should calculate and display the average of the numbers. The average should be included in an appropriate message. b. Repeat the exercise, making sure that you use the same variable name, number, for each input. Also use the variable sum for the sum of the numbers. (Hint: To do this, you must use the statement sum = sum + number; after each number is accepted. Review the material on accumulating, which is presented on pages 109-110 of the textbook.)
Assignment 4 (Chapter 4)
Choose one problem from the following: 1. Ask for a single character to be typed from the keyboard. Analyze the character and print out a message that it is: an alphabetic character (az or AZ) a digit (09) or a special character (anything else)
2. Write a C program to determine whether the year entered from the keyboard is a leap year. Display a message indicating whether the year is or is not a leap year. To calculate this problem, a year is a leap year if it is evenly divisible by 4 and not by 100, or if it is evenly divisible by 400. Check the remainder of the division statements by using the % function. (Hint: It may help to have three variables, each one holding the remainder of each of the division problems.) (To check your work, legal leap years are 1952, 1964, 1988, and 2004. Years 1953, 1966, 1990, and 2007 are not leap years.)
Assignment 5 (Chapter 5)
Choose one problem from the following: 1. Write a program to generate and display a table of n and n2, for integer values of n ranging from 1 through 10. Be sure to print appropriate column headings. 2. Write a C program that prompts for a variable number of integers, adds them up, averages them, and prints out the average.
S-11
The user will enter either an integer to be averaged or a sentinel of 999 indicating that no more numbers are to be entered. When the sentinel is entered, the program will exit the repetition loop. It will then compute and display the average of numbers entered.
2. Write a C function named liquid() that is to accept an integer number and the addresses of the variables gallons, quarts, pints, and cups. The passed integer represents the total number of cups, and the function is to determine the number of gallons, quarts, pints, and cups in S-12
the passed value. Using the passed addresses, the function should directly alter the respective variables in the calling function. Use the relationships of 2 cups to a pint, 4 cups to a quart, and 16 cups to a gallon. Include this function in a program, printing the results after the function has run. If the user enters 27 cups, the output should be:
1 2 1 1
and not:
Assignment 7 (Chapter 8)
Choose one problem from the following: 1. Write a program that reads a 5 x 5 two-dimensional array of integers and then prints the row sums and the column sums:
Enter row 1: 8 Enter row 2: 3 Enter row 3: 2 Enter row 4: 15 Enter row 5: 6 Row Totals: Column Totals:
3 5 8 7 14
9 17 6 3 2
0 1 23 2 6
10 1 1 9 0
You may either initialize this array within the program or have the user type in the values at run time. 2. Six stock prices (buying price) are stored into a 2 x 6 two-dimensional array. The user inputs the current price of each stock. This program will compare the buying price and the current price of each stock. It will print a table:
Stock 1
etc.
After the table is displayed, print out the stock with the highest profit if sold and its position in the array[row][column].
S-13
S-14
a single string. Display the assembled string using the puts() call back in main after the function has completed. B. 1. Create a structure that has one variable called value and one pointer to the list (making it a linked list). Prompt for 5 values from the keyboard as input and store them in the linked list. Print out the current contents of the list. Allow the user to add one more value to the linked list, and print the contents of the list again. 2. Write a C program that initially presents a menu of choices for the user. The menu should consist of the following choices:
A. Create an initial linked list of students and grades. B. Insert a new student into the linked list. C. Modify an existing student in the linked list. D. Delete an existing student from the linked list. E. Display the linked list. F. Exit from the program.
Upon the users selection, the program should execute the appropriate functions to satisfy the request.
Print out your results on the screen. B. 1. Create a set/list of enumerated constants called week that contains the days of the week. Have a variable called today that is of type week. Assign a value to today. If the day is Monday through Friday,
S-15
S-16