Exercises


  • The Coalition for the Protection of Nachos wants you to create a structure that defines all the great things about nachos. Create variables named nacho and fajita that list their favorite qualities, and then compare each of the two's qualities, each time giving one of the structures a tally mark (held inside the structure). At the end of the comparisons, figure out which is really better, a nacho, or a fajita.
  • Create a pointer to the structure from the problem above , and then use new to give it something to point at. Fill each of the attributes of the structure with a value and, at the end, print the value out.
  • Try passing a structure to a function.
  • Write a function that returns a structure. What are the advantages of returning a structure?
  • Take some of the examples from Chapter 2 and rewrite them to use \n instead of endl.
  • Write a program that moves the cursor down 10 lines.
  • Write a for using "i++" instead of "i = i + 1". Also, try using "i += 1" after that.


Table of Contents

Structures | Pointing to Structures | Using Pointers to Structures | Using Escape Codes
Shortcuts | Exercises