Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
print3
.
void print3(int d); void print3(int d) { if (d < 10) cout << "xx"; else if (d < 100) cout << "x"; cout << d; } |
void foo(int a, int& b); string bar(double k, string s); int i, j, k; double x, y, z; string u, v, w;
foo(3,4)
foo(i,j)
foo(i,j+k)
bar(3.0,4.0)
bar(x,u)
bar(x,u+v)
Enter fraction: -13/345877 Pretty print is: -13 ------ 345877In doing this, write a function
writefrac
that takes the numerator and denominator and prints out the
fraction. Make the function so that I could pretty-print my
fraction to a file or to the screen, even though your program
might not make use of that flexibility. Now, I'm not going to
tell you how to do your job, but writefrac
would be a piece of cake to implement, if only you had a
function length(int k)
that would tell you
how many characters would be required to print k
,
and maybe another function
rep(char c, int k, ostream& OUT)
that would print out k
copies of c
to the output stream OUT
. Of course, that's just
me.
1 ----- 23457