Sunteți pe pagina 1din 16

Directed Independent Adult Learning

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.

Strategies for Success


1. This Course Syllabus will guide you step-by-step through the text for the course. Each week you will consult the "Course Calendar," which will provide you with your weekly reading assignments and will help you determine the precise dates when assignments are due and exams are to be taken. 2. Read carefully the entire Course Essentials section of this syllabus, making sure that all aspects of the course are clear to you and that you have all the materials required for the course. 3. Take the time to read the entire Student Handbook section of the Course Manual. The handbook answers many questions about how to proceed through the course, how to prepare and submit assignments, how to schedule exams and arrange for proctors, and how to get the most from your educational experience at Thomas Edison State College. 4. Before you begin working on your assignments, take the time now to fill in the dates for the current semester on the "Course Calendar." The Weekby-Week dates you will need to plan your semesters work are located within the General Course Instructions section of this Course Manual. Once you fill out the calendar, you will know exactly when to begin your assignments, when they are due, and when to schedule your exams. 5. Staying on schedule is very important in a course like this one. Be sure to do all the assigned reading before you begin your written assignments. 6. Before starting the course, you should become familiar with the layout of the required text, paying particular attention to the brief chapter summaries and to the exercises that are presented at the end of almost every section in the textbook. It is suggested that you work out the exercise short-answer questions to help you study the course material. The answers for all short-answer questions are provided in Appendix G. It is suggested that you answer the questions before looking at the answers in the book. This will help you assess which concepts need further study.

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

Date Due or Exam Date

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

MIDTERM EXAMINATION (Chapters 17 and Assignments 16) 8 Written Assignment 7

S-7

Week

Date

Textbook Readings

Written Assignment

Date Due or Exam Date

9 10 11

11 9, 12, 13 10, 14

Written Assignment 8 Written Assignment 9 Written Assignment 10

12

FINAL EXAMINATION (Chapters 814 and Assignments 710)

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:

Enter a number: Enter a second number: Enter a third number:

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.

Assignment 6 (Chapters 67)


Choose one problem from the following: 1. Write a C function named change() that accepts a floating point number of total coins and the addresses of the integer variables named quarters, dimes, nickels, and pennies. The function should determine the number of quarters, dimes, nickels, and pennies in the total coins number passed to it and write these values directly into the respective variables declared in its calling function using pointers. Call the function change() from main() three times and print out the contents of the variables quarters, dimes, nickels, and pennies after each function return. First Callpass in the total value $1.88 and on return print the contents of the variables. Second Callpass in the total value .32 and on return print the contents of the variables. Third Call ask for a total value input from the keyboard and on return print the contents of the variables. Output should look like:

TOTAL VALUE ENTERED: 1.88 7 quarters 1 dime 0 nickels 3 pennies


and not:

TOTAL VALUE ENTERED: 1.88 7 quarters 18 dimes 37 nickels 188 pennies

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:

gallon quarts pint cup

1 gallon 6 quarts 13 pints 27 cups

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.

Buying Price 12.25

Current Price 15.00

Profit If Sold 2.75

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

Assignment 8 (Chapter 11)


Choose one problem from the following: 1. If you choose to answer problem 1 in Written Assignment 8, you must complete both parts a and b. a. Write a C program that has a declaration in main() to store the following numbers into an array named channels: 2, 4, 5, 7, 9, 11, 13. There should be a function call to display() that accepts the channels as an argument named channels and then displays the numbers using the pointer notation *(channels + i). b. Modify this display() function to alter the address in channels. Always use the expression *channels rather than *(channels + i) to retrieve the correct elements. 2. If you choose to answer problem 2 in Written Assignment 8, you must complete both parts a and b. a. Write a C program that has a declaration in main() to store the string "What's for lunch?" into an array named message. There should be a function call to restaurant() that accepts the message as an argument named menu and then displays the message using the pointer notation *(menu + i). b. Modify this restaurant() function to alter the address in message. Use the expression *menu rather than *(menu + i) to retrieve the correct element.

Assignment 9 (Chapters 9, 12, 13)


Choose one problem from the A section and one problem from B section. A. 1. Write a C program that accepts a month and day (for example, June 14) from the keyboard as input. Store this information in one string called date. Call a function named separate() passing in the string date and the addresses of a tempmonth array and tempday integer. The separate() function should extract the two values from the passed string and store them into the passed variable addresses. Back in main, print the data in tempmonth and tempday. 2. Write a C program that accepts as input from the keyboard a floating point number, an integer, and a character. Each of these inputs should be preceded by a prompt and stored using individual variable names. Have your program call a function that assembles the input data into

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.

Assignment 10 (Chapters 10, 14)


Choose one problem from the A section and one problem from B section. A. 1. Have a program prompt the user for a filename to open. Change every alphabetic character in the file to a capital letter. Numbers and special characters should not be changed. Print the output to the screen. 2. Write a program to prompt a user for a filename. Count: the number of characters in the file (letters or numbers) the number of words in the file the number of lines in the file

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

print "Go to work!" If the day is Saturday or Sunday, print

"You can rest today!"


2. If you choose to answer problem 2 in Written Assignment 10, you must complete both parts a and b. a. Define a macro named ECHO(str) that, when passed a string str, prints it out again on the screen. Be sure to enclose your macro in parentheses to keep it together when called within your program. b. Write a small program using your macro.

S-16

S-ar putea să vă placă și