[ create a new paste ] login | about

Link: http://codepad.org/jZbpecpm    [ raw code | output | fork | 1 comment ]

C, pasted on Aug 31:
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
	int i, n;
	float x, S, T;
	long M, N;
	printf("\nNhap x: ");
	scanf("%f", &x);
	do
	{
	printf("\nNhap n(n >= 1) : ");
	scanf("%d", &n);
	  if(n < 1)
	  {
		  printf("\n N phai >= 1. Xin nhap lai !");
	  }

	}while(n < 1);

	S = 1;
	N = 1;
	i = 1;

	while(i <= n)
	{
		
		T = pow(x, (2 * i + 1));
		M = i * 2 + 1;
		N = N * M * (M - 1);
		S = S + pow(-1, (float)(i + 1)) * T/N ;
		i++;
	}
	printf("\nTong la %f", S - x);
	getch();
	return 0;
}


Output:
1
Line 17: error: conio.h: No such file or directory


Create a new paste based on this one


Comments:
posted by tothanh10061997 on May 1
s= 1 +x^3/3!-..+.. ko co -x sai roi

reply