\magnification1200
\def\frac#1#2{{{\textstyle#1}\over{\textstyle#2}}}
\def\lb{$\{$}
\def\rb{$\}$}
\def\\{$\backslash$}

\newcount\pc\pc=1
\def\pr{\ifnum\pc>1 \vfill\eject\fi\par\noindent{\bf \number\pc.}\ \advance\pc by1}
\headline{\hfill Name: \vrule width 2in height .1pt depth 0pt}

\centerline{\bf Math 211 Final}
\centerline{May 5, 1999}
\pr
If we solve the second order differential equation 
$$y^{\prime\prime}=y^\prime+y$$
with initial
condition $y(0)=1$ and $y^\prime(0)=2$
via power series method $y=\displaystyle\sum_{n=0}^\infty a_nx^n$,
we get
$a_0=1$, $a_1=2$ and
$$a_n=\frac{a_{n-1}}{n}+\frac{a_{n-2}}{n(n-1)}
$$
for $n>1$.
Write a function with declaration
\vskip8pt
\hskip 1in{\tt double coef(short n);}
\vskip8pt
\noindent
which recursively computes $a_n$:e.g. the statement
{\tt d=coef(3);}
should put 0.8333... into {\tt d}.

\vskip8pt
\noindent
{\tt double coef(short n)\lb/* Your code here */}


\pr First, describe roughly what the following program does.
Then assume the program has been compiled to produce {\tt a.out}.
If the file {\tt xx} consists of one line,

{\tt Aardvarks are animals.}

\noindent
describe the output of the line

{\tt a.out < xx}
\bigskip
\hskip10pt\vbox{\hsize=4in{\parindent=0pt\obeylines\tt
\#include <stdio.h>
\vskip10pt
main ( )\lb
int ix, iy, cc;
\vskip4pt
ix=iy=0;
while ( (cc=getchar())!=EOF ) \lb
\hskip20pt if(cc=='A') ix++;
\hskip20pt else if( cc=='a') ++iy;
\hskip20pt \rb
printf("\%d\\t\%d\\n",ix,iy);
\rb
}}

\pr
As discussed in class and on last year's final, the order of
evaluation of variables is not determined by the rules of C.
Discuss the two possible outputs for the program
\vskip4pt
\hskip 10pt\vbox{\hsize=4in{\parindent=0pt\obeylines\tt
\#include <stdio.h>
\vskip10pt
main ( )\lb
char cc;
cc='A';
printf("\%c\\t\%c\\n",++cc,cc++);
printf("\%c\\n",cc);
\rb
}}

\pr
This test was prepared in \TeX, a mathematical typesetting 
language.
One drawback occurs in trying to typeset working C programs.
Just cutting and pasting a C program produces garbage: indeed
\TeX\ usually chokes and produces no output at all.
One solution is to do a cut and paste and then modify the 
resulting file, but this is subject to the usual pitfalls.
As a first step in a program to help me manage this problem,
write a short C program which reads characters from
standard input. 
There are three ``special'' characters, the {\tt '\#'}, the
{\tt '\%'} and the {\tt '\\'} itself.
Each character is checked to see if it is special.
If it is not, just put it into the output stream, standard out.
If it is a special character, then first put a {\tt '\\'} into the
output stream and follow it with the special character you just read.
Finally, the last character in the output stream should be a newline
character so that the prompt ends up at the left edge of the
screen on a line by itself.

As an example, consider the last line of the program above

\noindent{\tt printf("\%c\\n",cc);}

\noindent If this is line is input to your program, you should get out the
following stream of characters

\noindent{{\tt\hfuzz=10pt
printf("\\\%c\\\\n",cc);
\par
}}
\noindent
in standard output.

\pr
Given the declarations as below, actually preform the indicated
calculation to 2 decimal places as C would perform them.

\vbox{{\obeylines\hsize=4in\tt
double  xx;

xx=5.0/6+4/3-(3+2)/6;
}}

\end
