Lab 3
The purpose of this lab is to give you some experience with type conversion
and type casting.
When you finish this lab you should:
- See the effects of integer division
- See the effects of type casting
- See a roundoff error.
Write a program, this program has no purpose other then demonstrating
the above concepts. Feel free to add other assignment and output statements
to help you understand the concept.
For each section, add comments answering the question (what happened and why).
- declare two integer variables a, and b.
- declare floating point variables x, and y;
- set a =10, b=5;
- let c= a/b, print out c
- let c= b/a, print out c
- What happened and why?
- let x = 1/a;
- print x
- what happened and why?
- let x = 1/float(a);
- print out x
- what happened and why?
- let y = x*a;
- print out y
- let y = 1-x*a;
- print out y
- What happened and why?
When you have finished this program, email the .C file to dbennett@edinboro.edu.