[ create a new paste ] login | about

Link: http://codepad.org/25jWeIkn    [ raw code | output | fork ]

C, pasted on Sep 14:
#include<stdio.h>
#include<conio.h>

long tong(int n)
{
	long s = 0;
	int i = 1;
	while(i <= n)
	{
		s = s + i;
		i++;
	}
	return s;
}

int main()
{
	int n;
	printf("\nNhap n: ");
	scanf("%d", &n);
	
	long ketqua = tong(n);
	printf("\nTong = %ld", ketqua);

	getch();
	return 0;
}


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


Create a new paste based on this one


Comments: