CISC 105 Lab 06 FAQ

For each of the following questions, I'll give suggestions for "troubleshooting" the problem.

Notes from Sara:

COMMENTS! You should include high-level descriptions for both your programs and your functions.

Refer to the C coding standards to remind yourself what we expect of your code. ALIGN CODE and HAVE GOOD STYLE. I'm taking off mucho points for code that's hard to read. Name your variables and functions well. You have had plenty of warning.

Why are global variables poor style?

For now, we're just telling you not to do them. Global variables become troublesome as your programs get larger. The problem with global variables is that you increase the chance that something will be changed in a way that you didn't expect. By definition (since you didn't expect it), this is hard to debug. If your subroutine does change a global variable, you should document this in the subroutine header comment.

lab06.3.c: What's the height of the Empire State Building?

Silly... That's what Google is for!

lab06.4.c: I don't understand what's happening in number 4

The goal is to find n^x using recursion. It may be too hard to figure out n^x, but you know that n^x is just n*n^(x-1). So, you ask your friend to figure out what n^(x-1) is. The way she figures it out is that n^(x-1) is n*n^(x-2). She then asks someone else what n^(x-2) is, etc. The problem gets keeps getting "simplified" until n^0 because any number to the 0 power is 1. Then, when you get the answer back to your "too hard" problem, you can figure out the final answer.

lab06.4.c: Should we handle negative exponents?

Yes, but it is sufficient (and expected) to check if the exponent is negative and give back an appropriate response.

lab06.4.c: How do I print a line of asterisks without a carriage return?

The point here is just that we want to see

and not