Perulangan

Contoh bikin KRS pake perulangan :

#include<conio.h>

#include<iomanip.h>

#include<iostream.h>

main()

{

int i,j, sks[1], jml_sks,jml_mkul;

char no_mhs[5],nama[20],kode_mkul[10][20],mkul[20][20],dosen[20][20];

jml_sks=0;

cout<<“Kartu Rencana Studi”<<endl;

cout<<“************************************************”<<endl;

cout<<“No Mahasiswa : “;cin>>no_mhs;

cout<<“Nama Mahasiswa : “;cin>>nama;

cout<<“Jumlah MK yang akan di ambil : “;cin>>jml_mkul;

cout<<“************************************************”<<endl;

j=1;

for (i=0;i<jml_mkul;i++)

{

cout<<“Matakuliah ke-“<<j++<<endl;

cout<<“Kode MK : “; cin>>kode_mkul[i];

cout<<“Nama MK : “; cin>>mkul[i];

cout<<“Jumlah SKS : “; cin>>sks[i];

cout<<“Nama Dosen : “; cin>>dosen[i];

jml_sks=jml_sks+sks[i];

cout<<“************************************************”<<endl;

}

cout<<endl;

cout<<“===========****KARTU RENCANA STUDI****==========”<<endl;

cout<<“————————————————“<<endl;

cout<<“No Mahasiswa : “<<no_mhs<<endl;

cout<<“Nama : “<<nama<<endl;

cout<<“++++++++++++++++++++++++++++++++++++++++++++++++”<<endl;

cout<<setiosflags(ios::left)<<setw(5)<<“No.”;

cout<<setiosflags(ios::left)<<setw(10)<<“Kode MK”;

cout<<setiosflags(ios::left)<<setw(20)<<“Mata Kuliah”;

cout<<setiosflags(ios::left)<<setw(5)<<“SKS”;

cout<<setiosflags(ios::left)<<setw(25)<<“Dosen”<<endl;

cout<<“^^^^^^^+++++++++++++^^^^^^^^^^^^^^^^^^^^^^^^^^^^”<<endl;

j=1;

for (i=0;i<jml_mkul;i++)

{

cout<<setiosflags(ios::left)<<setw(5)<<j++;

cout<<setiosflags(ios::left)<<setw(10)<<kode_mkul[i];

cout<<setiosflags(ios::left)<<setw(20)<<mkul[i];

cout<<setiosflags(ios::left)<<setw(5)<<sks[i];

cout<<setiosflags(ios::left)<<setw(25)<<dosen[i]<<endl;

}

cout<<“++++++++++++++++++++++++++++++++++++++++++++++++”<<endl;

cout<<“=======================Total SKS : “;

cout<<setiosflags(ios::left)<<setw(40)<<jml_sks;

getch();

}

Hasilnya :

perulangan.jpg

Posted on Januari 8, 2008, in C++ and tagged , , , . Bookmark the permalink. Tinggalkan komentar.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: