APS 105


APS 105 — Computer Fundamentals
Lab 5: Functions, Logic, and Debugging
Winter 2021
The goal of this laboratory is to practice the material on functions. You are to write one C program that
consists of a main() and several functions. The program displays the Pascal’s triangle as explained in the
following section.
Preparation
Read through this entire document carefully, and do the work to create the programs that are described
below. You are encouraged to:
▪ Read the class bulletin board on Piazza, to see if others had similar problems. If you do not see
anything helpful there, ask a question. Do not ask for, or ever give a full or partial solution to the
lab assignment.
▪ Ask for assistance from your lab/tutorial TAs.
▪ Attend and ask questions during the plenary sessions.
Notes:
 In the sample output examples that follow:
o The text <enter> stands for the user pressing the enter key on the keyboard. On some
keyboards, the enter key may be labeled return代写APS 105编程
 Throughout this lab, there is a single space after the colon (:) in each output line.
Pascal’s Triangle
In a file called Lab5.c, write a C function named “triangle” that outputs Pascal’s triangle (for example) as
follows:
2
In general the Pascal’s triangle can be represented as:
0C0
1C1 1C0
2C2 2C1 2C0
3C3 3C2 3C1 3C0
4C4 4C3 4C2 4C1 4C0
...
where nCr represents how many ways there are to choose r from n, not counting duplicates.
In mathematics, it is usually presented as . The formula used to calculate nCr can be written as:

上一篇:POJ - 1062 - 昂贵的聘礼 = Dijkstra


下一篇:2021-03-01