[ create a new paste ] login | about

Link: http://codepad.org/Fda2t8YX    [ raw code | output | fork | 4 comments ]

C, pasted on Aug 20:
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
	int i, n;
	float S, M;
	do
	{
		printf("\nNhap n(n >= 1): ");
		scanf("%d", &n);

		if(n < 1)
		{
			printf("\nn phai >= 1. Xin nhap lai !");
		}
	}while(n < 1);
	i = 1;
    M = 1;
	S = sqrt((float)0);

	while(i <= n)
	{
		M = M * i;
		S = sqrt(M + S);
		i++;
	}
	printf("\nTong la %f", S);

	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 yonnon on Jul 5
Khó vãi luôn á
reply
posted by yonnon on Jul 5
má bị dụ =)) hiểu rồi tks
reply
posted by cuong.luucb8921 on Aug 19
#include<stdio.h>

int main(){
int i;
int n;
float s=0;
int t=1;
do
{
printf("Nhap vap n:\n");
scanf("%d",&n);
if(n < 1)
{
printf("n phai lon hon bang 1\n");
}
}while(n < 1);

for(i=1;i<=n;i++)
{
t = t*i;
s = sqrt(t+s);
}
printf("sum = %f",s);
return 0;
}

reply
posted by phamquanghoaz on Aug 29
#include<stdio.h>
#include<math.h>
int main(){
int n;
printf("nhap n: ");
scanf("%d",&n);
double s ;
int tich = 1;
s = sqrt((double)tich);
for(int i = 2; i <= n; i++){
tich *= i;
s = sqrt(tich+s);
}
printf("%f ",s);
return 0;
}
reply