Home
61.
Is it true that a while statement can be used and still get the same results as coding a for statement?

Yes, a while statement can accomplish the same task as a for statement, but you need to do two additional things. You must initialize any variables before starting the while command, and you need to increment any variables as a part of the while loop.

62.
What must you remember when nesting statements?

You can’t overlap the loops. The nested loop must be entirely inside the outer loop.

63.
Can a while statement be nested in a do...while statement?

Yes, a while statement can be nested in a do...while loop. You can nest any command within any other command.

64.
What are the four parts of a for statement?

The four parts of a for statement are the initializer, the condition, the increment, and the statement(s).

65.
What are the two parts of a while statement?

The two parts of a while statement are the condition and the statement(s).

66.
Why should I use puts() if printf() does everything puts() does and more?

Because printf() does more, it has additional overhead. When you’re trying to write a small, efficient program, or when your programs get big and resources are valuable, you will want to take advantage of the smaller overhead of puts(). In general, you should use the simplest available resource.

67.
Why do I need to include stdio.h when I use printf(), puts(), or scanf()?

stdio.h contains the prototypes for the standard input/output functions. printf(), puts(), and scanf() are three of these standard functions. Try running a program without the stdio.h header and see the errors and warnings you get.

68.
What happens if I leave the address of operator (&) off a scanf() variable?

This is an easy mistake to make. Unpredictable results can occur if you forget the address of operator. When you read about pointers on Days 9 and 13, you will understand this better. For now, know that if you omit the address of operator, scanf() doesn’t place the entered information in your variable, but in some other place in memory. This could do anything from apparently having no effect to locking up your computer so that you must reboot.

69.
What is the difference between puts() and printf()?

There are two differences between puts() and printf():
printf() can print variable parameters.
puts() automatically adds a newline character to the end of the string it prints.

70.
What do the following escape sequences do?
a. \\
b. \b
c. \n
d. \t
e. \a

a. \\ prints a backslash.
b. \b prints a backspace.
c. \n prints a newline.
d. \t prints a tab.
e. \a (for "alert") sounds the beep.