//This program is designed to show the shortcomings of computer math.

/*
Algorithm:
1. Declare two integer variables, x, and y.
2. Let x = 1 and y = 2.
3. Declare a floating point variable (decimal), z, to hold the result of the division.
4. Divide x by y and store the result in z. 
5. Print out the value. Since you didn't typecast, it will be 0, since C decided to do integer level math.
6. Divide x by y, but typecast x so that it is a float. Store the result in z.
7. Print out z again. Since you typecasted, C chose to do floating point math, and z will be 0.5.

*/

#include <stdio.h>

int main(void){
	//declare x and y and set them equal to 1 and 2 respectively
	int x = 1;
	int y = 2;

	//declare z, a floating point
	float z;

	//divide x by y and store the result in z
	z = x / y;

	//print out z. because x and y were integers, C chose integer level math, so it will print out 0
	printf("Before typecast: %f \n",z);

	//divide x by y while typecasting x to float; store results in z
	z = (float)x / y;

	//print out z. because x temporarily became a float, C chose floating point math, so it will print out 0.5
	printf("After typecast: %f \n",z);


	return 0;
}	
