[ create a new paste ] login | about

Link: http://codepad.org/fox1Nn60    [ raw code | output | fork | 2 comments ]

C, pasted on Aug 17:
#include<stdio.h>
#include<conio.h>

int main()
{
	int i, n;
	float x, S, T;
	long M;
	printf("\nNhap x: ");
	scanf("%f", &x);
	do
	{
	printf("\nNhap n: ");
	scanf("%d", &n);
	  if(n < 1)
	  {
		  printf("\n N phai >= 1. Xin nhap lai !");
	  }

	}while(n < 1);

	S = 0;
	T = 1;
	M = 0;
	i = 1;

	while(i <= n)
	{
		T = T * x;
		M = M + i;
		S = S + T/M;
		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 Vodong on Sep 1
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
for(float S=0,y=1,k=0,x,N,a=1;S==0;S=0,y=1,k=0,a=1)
{
cout<<"Nhap x,N: ";
cin>>x>>N;
for(;y<=N;++y)
{
for(;a<=y;++a)
{
k=k+a;
}
S=S+pow(x,y)/k;
}
cout<<"S="<<S;
cout<<endl;
}
return 0;
}
reply
posted by lethi200397 on Oct 10
#include<stdio.h>
#include<conio.h>
int main()
{
int i=1, n, x;
float T= 0, t = 0 ;
printf(" nhap vao x va n \n ");
scanf("%d%d", &x, &n);
while(i<=n)
{
t = t + i;
T = T + pow(x,(i/t));
i++;
}
printf("t = %f", t);
printf("T = %f", T);
getch();
return 0;
}

reply