C language Programming: A ball from 100 meters height free to fall, each landing after bounce back to the original height of half, and then fell, and asked it to the 10th time when the landing, a total of how many meters,? How high is the tenth rally?

Source: Internet
Author: User
A ball from the height of 100 meters free to fall, every time after landing back to the original height of half, and then fell, and asked it to the 10th time, the total number of meters,. How high the tenth rebound.
#include <stdio.h>
#include <stdlib.h>
float height_meter (int n)
{
	float height = 100.0;
	int i = 0;
	float meter = 100.0;
	if (n = = 1)
	{
		printf ("1th time after landing 100 meters, bounce 0 m \ n");

	}
	else
	{for
		(i = 2; I <=n; i++)
		{
			 height = HEIGHT/2;
			Meter = meter + height*2;
			printf ("%d total%f m, bounce%f m \ n", i,meter,height);}}
int main ()
{
	int n = 0;
	printf ("Plesse Enter N:");
	scanf ("%d", &n);
	Height_meter (n);
	System ("pause");
	return 0;
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.