Thursday, 5 December 2013

Program NIlai Dan Input Nama C++ Array


#include<iostream.h>
#include<stdio.h>
#include<conio.h>
void main()
{
int siswa_ke[3];
char nama[3][20];
int mid[3];
int final[3];
int rata[3];
int ulang;
for(ulang = 0; ulang <3; ulang++)
{
 siswa_ke[ulang]=ulang+1;
 cout<<"Input Nilai Mid : ";
 cin>>mid[ulang];
 cout<<"masukkan nama: ";
 cin>>nama[ulang];
 cout<<"Input Nilai Final : ";
 cin>>final[ulang];
 rata[ulang]=(mid[ulang]+final[ulang])/2;
}
 cout<<"--------------------------------------------------------------"<<endl;
 cout<<"| Siswa Ke | NAMA | MID | FINAL | RATA-RATA |"<<endl;
 cout<<"--------------------------------------------------------------"<<endl;
for(ulang = 0; ulang <3; ulang++)
{
 cout<<"|   "<<siswa_ke[ulang]<<"      ";
 cout<<"|  "<<nama[ulang]<<"   ";
 cout<<"|  "<<mid[ulang]<<" ";
 cout<<"|   "<<final[ulang]<<"  ";
 cout<<"|    "<<rata[ulang]<<"     |"<<endl;
}
 cout<<"--------------------------------------------------------------";
getch();
}

No comments:

Post a Comment