int main()
{	
	double first_height, ratio, rebound, vertical;/*define doubles*/
	int count;/*defines the integer count number*/

	FILE *outp;/*define the output file*/
	outp=fopen("Result_Table.txt", "w");/*create the output file*/	
	srand(time(NULL));/*first value for rand function*/
	ratio=(rand()%4000)/10000.0000+0.4;/*create the ratio between 0.4-0.8 */
	first_height=rand()%40;/*create the first height between 0 and 40*/
	if (first_height<10) {
	first_height=first_height+10;/*create the first height between 10 and 40*/
	}

	printf("ratio %f \n", ratio);/*print to screen ratio*/
	rebound=first_height;/*define the first height for rebound*/
	vertical=first_height;/*define the first height for total vertical*/
	count=1;/*define the first count*/
	/*print to screen/output file values kind name*/
	printf("No – The Rebounching Height -- The Total vertical Distance\n");
	fprintf(outp, "No – The Rebounching Height -- The Total vertical Distance\n");
	/*this loop repeat as long as rebound<1. */
	while(rebound>=LIMIT) {
		/*print to screen/file count,rebound,total vertical values*/
		report(count, rebound, vertical, outp);
		/*calculate the new height from rebound and ratio*/
		rebound=calculate_the_new_height(rebound,ratio);
		/*calculte the vertical from old vertical and rebound.*/
		vertical=calculate_the_vertical_distance(vertical, rebound);
		/*calculate the count number.*/
		count=count_the_number(count);
	}
	/*print to screen/file text for finish to calculate and program. */ 
	printf("The bouncing is stopped and the task completed...\n");
	fprintf(outp, "The bouncing is stopped and the task completed...\n");
	fclose(outp);/*close to output file.*/

	return 0;

}
	/*To print No, The Rebouncing Height,The Total Vertical Distance*/
void report(int first_height,double ratio){

	int no=ZERO,no_txt=ZERO;
	double rebounching_height;
	double vertical_distance;
	double new_bounching;
	double new_bounching_txt;

	FILE *outp;

	vertical_distance = first_height; /*Total vertical Distance*/
	new_bounching_txt = first_height; /*last Rebounching Height*/
	no = count_the_number(no);		  /*calculate no for console*/
	no_txt = count_the_number(no_txt);/*calculate no for txt file*/

	printf("No  - ");
	printf("The Rebounching Height -- ");
	printf("The Total Vertical Distance\n");

	printf("%d       ",no);
	printf("   %.3f         ",vertical_distance);
	printf("          %.3f\n",vertical_distance);
	
	outp = fopen("Result_Table.txt","w");
	
	fprintf(outp,"%d   ",no_txt);
	fprintf(outp,"%.3f   ",vertical_distance);
	fprintf(outp,"%.3f\n",vertical_distance);


	
	while(new_bounching_txt >= LIMIT_HEIGHT){
	
	rebounching_height = calculate_the_new_height(new_bounching_txt,ratio);
	vertical_distance += calculate_the_vertical_distance(rebounching_height);
	no_txt = count_the_number(no_txt);
	 
	/*necessary for  the control while function*/
	new_bounching_txt = rebounching_height;
		
		if(new_bounching_txt >= LIMIT_HEIGHT){
			
			fprintf(outp,"%d   ",no_txt);
			fprintf(outp,"%.3f   ",rebounching_height);
			fprintf(outp,"%.3f\n",vertical_distance);
		}
	}

	fclose(outp);

	vertical_distance = first_height;
	new_bounching = first_height;

	while(new_bounching >= LIMIT_HEIGHT){
	
	rebounching_height = calculate_the_new_height(new_bounching,ratio);
	vertical_distance += calculate_the_vertical_distance(rebounching_height);
	no = count_the_number(no);

	/*necessary for  the control while function*/
	new_bounching = rebounching_height;
		
		if(new_bounching >= LIMIT_HEIGHT){
			
			printf("%d       ",no);
			printf("   %.3f         ",rebounching_height);
			printf("          %.3f\n",vertical_distance);
		}
	}

	printf("The bouncing is stopped and the task completed...\n");
	printf("First Height=%d and ", first_height);
	printf("ratio=%.2f\n", ratio);

}