View Code of Problem 72

#include<stdio.h>
int main()
{
	double h;
	int n;
	scanf("%lf %d",&h,&n);
	double sum=h;
	for(int i=0;i<n;i++)
	{
		h=h/2;
		if(i!=(n-1))
		  sum+=(2*h);
	}
	printf("%.2f %.2f",h,sum);
} 

Double click to view unformatted code.


Back to problem 72