View Code of Problem 71

#include<stdio.h>
int main()
{
	float a,b,t;
  	int n;
  	float sum=0;
  	scanf("%d",&n);
  	a=1.0;b=2.0;
  	for(int i=0;i<n;i++)
        {
        	sum=sum+b/a;
          	t=b;
          	b=a+b;
          	a=t;
        }
  	printf("%.2f\n",sum);
  return 0;
}

Double click to view unformatted code.


Back to problem 71