Workshop
To help solidify your understanding of this hour's lesson, you are encouraged to answer the quiz questions and finish the exercises provided in the Workshop before you move to the next lesson. The answers and hints to the questions and exercises are given in Appendix E, "Answers to Quiz Questions and Exercises."
Quiz
- Can you align your output at the left edge, rather than the right edge, of the output field?
- What is the difference between putc() and putchar()?
- What does getchar() return?
- Within %10.3f, which part is the minimum field width specifier, and which one is the precision specifier?
Exercises
- Write a program to put the characters B, y, and e together on the screen.
- Display the two numbers 123 and 123.456 and align them at the left edge of the field.
- Given three integers–15, 150, and 1500–write a program that prints the integers on the screen in the hex format.
- Write a program that uses getchar() and putchar() to read in a character entered by the user and write the character to the screen.
- If you compile the following C program, what warning or error messages will you get?
main()
{
int ch;
ch = getchar();
putchar(ch);
return 0;
}
- 4 views