PROGRAM ARRAY C++ DAN PASCAL

PROGRAM ARRAY C++

#include<iostream.h>
#include<conio.h>
main()
{
int matrix[3][3];
int i,j;

for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<"Masukkan Nilai Angka Pada Baris Ke "<<i<<" dan Kolom Ke "<<j<<" : ";
cin>>matrix[i][j];
}
cout<<endl;
}
for(i=0;i<=2;i++)
{
for(j=0;j<=2;j++)
{
cout<<matrix[i][j]<<" ";
}
cout<<endl;
}
getch();
}


PROGRAM ARRAY PASCAL

USES CRT;
VAR
  I         :LONGINT;
  NM        :ARRAY[1..100]OF STRING[25];
  HK,SUBT   :ARRAY[1..100]OF REAL;
  LM        :ARRAY[1..100]OF INTEGER;
  TOT       :REAL;
                                                           
BEGIN
  I:=1;
  WHILE(I<=3) DO
      BEGIN
        WRITELN('DATA KE :',I);
        WRITELN('===========');
        WRITE('INPUTKAN NAMA TAMU :');READLN(NM[I]);
        WRITE('INPUTKAN LAMA MENGINAP :');READLN(LM[I]);
        WRITE('INPUTKAN HARGA KAMAR :');READLN(HK[I]);
        SUBT[I] :=LM[I] * HK[I];
        WRITELN;
        TOT :=TOT + SUBT[I];
        I:=I +1;
      END;
  WRITELN('--------------------------------------------------');
  WRITELN('NO            NAMA   LAMA        HARGA   SUB      ');
  WRITELN('              TAMU   MENGINAP    KAMAR   TOTAL    ');
  WRITELN('--------------------------------------------------');
      FOR I:=1 TO 3 DO
        BEGIN
          WRITELN(I:3,NM[I]:15,LM[I]:10,HK[I]:10:0,SUBT[I]:8:0);
        END;
  WRITELN('--------------------------------------------------');
  WRITELN('TOTAL :',TOT:12:0);

END.   

1 komentar:

Computer Tips and Tricks

mantaf gan izin cb...

mmpir gan...
http://belprog.blogspot.com

Posting Komentar