Senin, 31 Oktober 2016

ARRAY

LIST PROG ARRAY

#include<conio.h.>
#include<iostream.h>
#include<stdio.h.>
#include<iomanip.h>
main()
{
int i;
   char nama[5] [20];
   float nilai1 [5];
   float nilai2 [5];
   float hasil [5];
   clrscr ();
   for (i=1;i<=2;i++)
   {
   cout<<"Data ke- "<<i<<endl;
   cout<<"Nama Siswa             :";gets(nama[i]);
   cout<<"Nilai Teori            :";cin>>nilai1[i];
   cout<<"Nilai Praktek          :";cin>>nilai2[i];
   hasil[i]=(nilai1[i]*0.40)+(nilai2[i]*0.60);
   cout<<endl;
   }
clrscr();
   cout<<endl<<endl;
   cout<<"--------------------------------------------------"<<endl;
   cout<<"No.     Nama Siswa                        Nilai                       Nilai                       Hasril                     "<<endl;
   cout<<"                                                                                                             Teori                      Praktek                Ujian                                     "<<endl;
   cout<<"---------------------------------------------------"<<endl;
   for (i=1;i<=2;i++)
   {
                cout<<setiosflags (ios::left)<<setw(4)<<i;
      cout<<setiosflags(ios::left)<<setw(18)<<nama[i];
      cout<<setprecision(2)<<"      "<<nilai1[i];
      cout<<setprecision(2)<<"      "<<nilai2[i];
      cout<<setprecision(2)<<"      "<<hasil[i]<<endl;
   }
   cout<<"---------------------------------------------------"<<endl;
   getch();
}

Tidak ada komentar:

Posting Komentar