Monday, April 16, 2012
TABEL PANGKAT
#include <iomanip.h>
#include <iostream.h>
#include <conio.h>
void main()
{
int kubik[10],pangkat[10],k,total,jumlah,jp,jk,jj;
jumlah=0;
jk=0;
jp=0;
jj=0;
cout<<"Bilangan"<<setw(13)<<"Pangkat"<<setw(11)<<"Kubik"<<setw(13)<<"Total"<<endl;
for(int i=0;i<10;i++)
{
k=i+1;
pangkat[i]=k*k;
kubik[i]=k*k*k;
total=k+pangkat[i]+kubik[i];
jumlah=jumlah+k;
jp=jp+pangkat[i];
jk=jk+kubik[i];
jj=jj+total;
cout<<setw(7)<<k<<setw(12)<<pangkat[i]<<setw(12)<<kubik[i]<<setw(13)<<total<<endl;
}
cout<<"-------------------------------------------------------------------------- +\n";
cout<<setw(7)<<jumlah<<setw(12)<<jp<<setw(12)<<jk<<setw(13)<<jj<<endl;
}
Labels:
Algoritma dan Pemrograman
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment