You are on page 1of 1

#include <iostream>

#include <cmath>
using namespace std;
/*float jumlah_deret(float n)
{
return jml;
}*/
main()
{
float n,i,x,hasil;
float jml;
cout<<"\n\t::::::::::::::::::::::::::::::::::::::::::"<<endl;
cout<<"\t
MENGHITUNG JUMLAH DERET
"<<endl;
cout<<"\t::::::::::::::::::::::::::::::::::::::::::"<<endl<<endl;
cout<<"\tMasukkan batas nilai n = ";
cin>>n;
jml=0;
for(i=1; i<=n; i++)
{
jml=((pow(-1,i))/((2*i)-1))+jml;
}
cout<<"\n\t------------------------------------------"<<endl;
cout<<"\tJumlah deretnya adalah = "<<jml<<endl;
cout<<"\n\n\n";
return 0;
}

You might also like