Program Jumlah Suku C++
#include <conio.h>
#include <iostream>
using namespace std;
int main()
{
int n;
printf("");
cout << "jumlah suku :";
cin >> n;
float result = 1;
for (int i=2; i<=n; i++)
result = result + (float) 1/i;
cout << "hasil :" << result << endl;
return 0;
}
Matur Sembah Nuwun
#include <iostream>
using namespace std;
int main()
{
int n;
printf("");
cout << "jumlah suku :";
cin >> n;
float result = 1;
for (int i=2; i<=n; i++)
result = result + (float) 1/i;
cout << "hasil :" << result << endl;
return 0;
}
Matur Sembah Nuwun
Komentar
Posting Komentar