Review Session 1

Example Code

Recording
These practice exercises will give you a head start into the class.  If you submit the exercise, it will be graded, just like a "real" exercise will be graded in the class.  You will get a grade and feedback on your submission, but it will not count in the actual class.  It is just for fun.  The real advantage of doing this now, is that you get to make mistakes and they won't count against your grade.  You will then know exactly what to expect when the real exercises come along.

Email only the source code for each practice exercise as an email attachment.  There is no due date.  Use "Practice Exercise #" as the email subject.   Add (a) comment(s) at the top of your program with your name, practice exercise #, your compiler and operating system.

Practice Exercise 1

Write a program in which you declare 5 variables, a, b, c, d, e.

  • a is an int initialized to a random number between 1 and 10
  • b is an unsigned short initialized to a random number between 2 and 11
  • c is a long initialized to a random number between 100 and 200
  • d is a float initialized to a divided by b
  • e is a double initialized to c divided by d
Note: assume that between means inclusive

Print a, b, and c on 3 separate lines.
Print d and e on the same line left-justified in a field of width 10 with 3 decimal place accuracy.

Your output should look something like this (except for different random numbers):

2
9
172
0.222     774.000