[ create a new paste ] login | about

Link: http://codepad.org/6dKDfthn    [ raw code | output | fork ]

C, pasted on Sep 14:
#include<stdio.h>
#include<conio.h>
float tong(float, int);
float luythua(float, int);

float luythua(float x, int n)
{
	float t = 1;
	for(int i = 1; i <= n; i++)
	{
		t = t * x;
	}
	return t;
}

float tong(float x, int n)
{
	float s = 0;
	for(int i = 1; i <= n; i++)
	{
		s = s + luythua(x, i);
	}
	return s;
}

int main()
{
	int n;
	float x;

	printf("\nNhap n: ");
	scanf("%d", &n);

	printf("\nNhap x: ");
	scanf("%f", &x);

	float ketqua = tong(x, n);
	printf("\nTong: %f",ketqua);

	getch();
	return 0;
}


Output:
1
2
3
4
5
Line 17: error: conio.h: No such file or directory
In function 'luythua':
Line 9: error: 'for' loop initial declaration used outside C99 mode
In function 'tong':
Line 19: error: 'for' loop initial declaration used outside C99 mode


Create a new paste based on this one


Comments: