Tagged with S-Data

Program Deret C++

#include <iostream.h> #include <conio.h> class Deret { friend istream& operator>>(istream&, Deret&); friend ostream& operator<<(ostream&, Deret&); public: void cetak(); private: int bil; int i, k, sum; }; void Deret::cetak() { sum=0; k=0; for (i=1; k<=bil;i++){ if (k <= bil && (k+2)>=bil) break; k=(i*3)-2; sum+=k; cout << “Suku ke : ” << i << ” = ” … Continue reading