//Array
Dinamis
#include<iostream.h>
#include<conio.h>
void main ( )
{ int nilai [10] ,x;
cout<<"masukan
nilai !!\n\n";
for(x=0;x<10;x++)
{cout<<"nilai
angka :";
cout<<"\n\n
Output nilai : \n";
for
(x=0;x<10;x++);
{cout<<"\nNilai Angka : "<<nilai[x];}
getch( );
}
//Array dua Dimensi
#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();
}
//Struct data mahasiswa
#include <stdio>
#include <conio>
main()
{
struct orang
{
char nim[30],nama[40];
};
orang org[3];
printf("Masukan data : \n==================\n\n");
for (int i=0;i<1;i++)
{
printf("NIM\t= ");gets(org[i].nim);
printf("Nama\t= ");gets(org[i].nama);
printf("===================\n");
}
clrscr();
printf("Data yang telah dimasukan : \n==============================\n\n");
printf("| No. | NIM | Nama |\n");
for (int i=0;i<1;i++)
{
printf("|%5d|",i+1);
printf("%30s|",org[i].nim);
printf("%40s|",org[i].nama);
printf("\n");
}
getch();
}
0 komentar:
Post a Comment