Tuesday, August 12, 2014

Câu 1.21: viết chương trình tính tổng s= 1+ 1/3^2 + 1/5^2....+ 1/(2n+1)^2) với n nguyên dương nhập vào từ bàn phím

#include <conio.h>
#include <stdio.h>

floattong(int n)
{
       int i;
       floats=0;
       for(i=0;i<=n;i++)
              s+=1.0/((2*i+1)*(2*i+1));
       return s;
}
voidmain()
{
       int n;
       printf("\nNhap N=   ");
       scanf("%d",&n);
       printf("\n Tong s = %f",tong(n));
       getch();
}


No comments:

Post a Comment