/*PROGRAM BILANGAN*/
#include <ostream.h>
#include <conio.h>
#include <math.h>
#pragma argsused
int main()
{
int pil;
double bil,ganjil, hasil, op;
cout<<"Masukkan jumlah bilangan : ";
cin>> pil;
cout<<""<<endl;
bil=1;
hasil =0;
cout<<"Bilangan Ganjil : ";
for (op=1;op<=pil;op=op+1)
{
cout<<bil<<" ";
hasil =hasil + bil;
bil = bil+2;
}
cout<<""<<endl;
double lib,po,coba;
lib=0;
coba=0;
cout<<"Bilangan Genap : ";
while (lib<pil)
{
pil=pil+1;
cout<<lib<<" ";
coba=coba + lib;
lib = lib+2;
}
cout<<""<<endl;
cout<<""<<endl;
cout<<"Hasil Bilangan Ganjil : "<<hasil<<endl;
cout<<"Hasil Bilangan Genap : "<<coba;
getch();
}
0 komentar:
Posting Komentar