1 <!DOCTYPE HTML PUBLIC
"-//W3O//DTD W3 HTML 2.0//EN">
2 <!-- This collection of hypertext pages is Copyright 1995-7 by Steve Summit. -->
3 <!-- This material may be freely redistributed and used -->
4 <!-- but may not be republished or sold without permission. -->
7 <link rev=
"owner" href=
"mailto:scs@eskimo.com">
8 <link rev=
"made" href=
"mailto:scs@eskimo.com">
9 <title>Assignment #
1</title>
12 <H1>Assignment #
1</H1>
18 <B>Introductory C Programming
21 UW Experimental College
27 <br><a href=
"PS1.html">Assignment #
1</a>
28 <br><a href=
"http://www.eskimo.com/~scs/cclass/progintro/top.html">A Short Introduction to Programming
</a>
29 <br><a href=
"http://www.eskimo.com/~scs/cclass/mathintro/top.html">A Brief Refresher on Some Math Often Used in Computing
</a>
30 <br><a href=
"http://www.eskimo.com/~scs/cclass/notes/sx1.html">Class Notes, Chapter
1</a>
31 <br><a href=
"http://www.eskimo.com/~scs/cclass/notes/sx2.html">Class Notes, Chapter
2</a>
32 <br><a href=
"http://www.eskimo.com/~scs/cclass/handouts/avcompilers/index.html">Available Compiler Options
</a>
33 <br><a href=
"http://www.eskimo.com/~scs/cclass/handouts/errmsgs/top.html">Common Compiler Error Messages and Other Problems
</a>
34 <br><a href=
"http://www.eskimo.com/~scs/cclass/handouts/cstepbystep/index.html">Compiling C Programs: Step by Step
</a>
35 <p><B>Reading Assignment:
36 </B></p><p><a href=
"http://www.eskimo.com/~scs/cclass/progintro/top.html">A Short Introduction to Programming
</a>
37 <br><a href=
"http://www.eskimo.com/~scs/cclass/notes/sx1.html">Class Notes, Chapter
1</a>
38 <br><a href=
"http://www.eskimo.com/~scs/cclass/notes/sx2.html">Class Notes, Chapter
2</a> (optional)
39 <br><a href=
"http://www.eskimo.com/~scs/cclass/handouts/cstepbystep/index.html">Compiling C Programs: Step by Step
</a>
40 <p><B>Review Questions:
41 </B></p><OL><li>Approximately what is the line
<TT>#include
<stdio.h
></TT>
42 at the top of a C source file for?
43 <li>What are some uses for comments?
44 <li>Why is indentation important?
45 How carefully does the compiler pay attention to it?
46 <li>What are the largest and smallest values that can be reliably
47 stored in a variable of type
<TT>int
</TT>?
48 <li>What is the difference between the constants
49 <TT>7</TT>,
<TT>'
7'
</TT>, and
<TT>"7"</TT>?
50 <li>What is the difference between the constants
51 <TT>123</TT> and
<TT>"123"</TT>?
52 <li>What is the function of the semicolon in a C statement?
54 </B>(easy to harder; do as many as you like, but at least two)
56 Get the ``Hello, world!'' program to work on your computer.
57 If you're using a Unix machine, the instructions in the notes should
59 If you're using a commercial compiler on a home
60 computer, the compiler's instruction manuals should (really,
<em>must
</em>)
61 tell you how to enter, compile, and run a program.
63 ``
<a href=
"http://www.eskimo.com/~scs/cclass/handouts/csstepbystep/top.html">Compiling C Programs
</a>''
64 handout should help, too.)
66 What do these loops print?
68 for(i =
0; i
< 10; i = i +
2)
72 for(i =
100; i
>=
0; i = i -
7)
76 for(i =
1; i
<=
10; i = i +
1)
80 for(i =
2; i
< 100; i = i *
2)
84 Write a program to print the numbers from
1 to
10
94 Write a program to print this triangle:
107 Don't use ten
<TT>printf
</TT> statements; use two nested loops instead.
108 You'll have to use braces around the body of the outer loop if
109 it contains multiple statements:
111 for(i =
1; i
<=
10; i = i +
1)
113 /* multiple statements */
117 (Hint: a string you hand to
<TT>printf
</TT> does not have to contain the
118 newline character
<TT>\n
</TT>.)
122 This page by
<a href=
"http://www.eskimo.com/~scs/">Steve Summit
</a>
123 //
<a href=
"copyright.html">Copyright
</a> 1995-
9
124 //
<a href=
"mailto:scs@eskimo.com">mail feedback
</a>