Penjumlahan Bertingkat Dengan struktur kontrol Perulangan(repetion)
#include <cstdlib>
#include <iostream>
#include <string.h>
using namespace std;
int main(int argc, char * argv[])
{
int a, b, c, x, bil, jum_baris, jum_total;
jum_total=0;
masukan :
cout<<"Masukan Batas Bilangan: "<<endl;
cin>>x;
cout<<"\n";
for(a=1; a<=x; a++)
{
jum_baris=0;
bil=1;
for (b=1;b<=a;b++)
{
if ( b > 1)
{
cout<<"+";
}
cout<<bil;
jum_baris=jum_baris+bil;
bil=bil+1;
}
jum_total=jum_total+jum_baris;
cout<<" = "<<jum_baris;
cout<<endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
#include <iostream>
#include <string.h>
using namespace std;
int main(int argc, char * argv[])
{
int a, b, c, x, bil, jum_baris, jum_total;
jum_total=0;
masukan :
cout<<"Masukan Batas Bilangan: "<<endl;
cin>>x;
cout<<"\n";
for(a=1; a<=x; a++)
{
jum_baris=0;
bil=1;
for (b=1;b<=a;b++)
{
if ( b > 1)
{
cout<<"+";
}
cout<<bil;
jum_baris=jum_baris+bil;
bil=bil+1;
}
jum_total=jum_total+jum_baris;
cout<<" = "<<jum_baris;
cout<<endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
Komentar
Posting Komentar