Hasil Runing |
/*PROGRAM DERET*/
#include <iostream.h>
#include <conio.h>
#include <math.h>
#include <iomanip.h>
#pragma argsused
int main()
{
double jum,gan, gen, y, x;
double i;
cout<<"DERET BILANGAN FOR"<<endl;
cout<<"------------------"<<endl;
cout<<""<<endl;
cout<<"MASUKKAN JUMLAH BILANGAN : ";
cin>> jum;
cout<<""<<endl;
cout<<"GANJIL"<<setw(10)<<"GENAP"<<endl;
cout<<"------"<<setw(10)<<"-----"<<endl;
gan=1;
gen=0;
for (i=1; i<=jum; i=i+1)
{
cout<<setw(3)<<gan<<setw(11)<<gen<<endl;
x = x+gan;
y = y+gen;
gen =gen+2;
gan =gan+2;
}
cout<<"----------------"<<endl;
cout<<" ";
cout<<x<<setw(11)<<y<<endl;
cout<<""<<endl;
cout<<"JUMLAH BILANGAN GANJIL + GENAP = "<<x+y<<endl;
getch();
}
0 komentar:
Posting Komentar