- Data structures that contain data types that have the same type.
- A group of memory-related form of (contiguous).
- Arrays have the same name and type.
- To refer to a particular location or element in the array 1 array name + index.
Computer store has some sales that sell computer (with the unit size / fruit). The number of computers which successfully sold every sales per month from January to May 2011 is presented in the following table:
There is valuable information that could be obtained, for example, anyone who successfully sells computer sales ever etc.. Construction provisions of the data member:
1. list of sales: 1-dimensional array
2. computer sales: 2 dimensional array
3. Total and average sales per month and the total computers sold each successful sales: one-dimensional array
There is valuable information that could be obtained, for example, anyone who successfully sells computer sales ever etc.. Construction provisions of the data member:
1. list of sales: 1-dimensional array
2. computer sales: 2 dimensional array
3. Total and average sales per month and the total computers sold each successful sales: one-dimensional array
1.input and print a 1-dimensional arrays
for (i=0; i<rows;i++){
cout<<"data ke-"<<i+1<<" : ";
cin>>a[i];}
for (i=0;i<columns;i++)
cout<<a[i]<<" ";
cout<<endl;
2. Input print n 2 dimensional array
:for (i=0; i<rows;i++){
for (j=0;j<columns;j++){
cout<<"data ["<<i+1<<","<<j+1<<"] : ";
cin>>a[i][j];}}
for (i=0;i<rows;i++){
for (j=0;j<columns;j++)
cout<<a[i][j]<<" ";
cout<<endl;}
3. Addition and rata2
# include <iostream>
# include <conio.h>
int main () {
int i, n;
float average, number;
int data [10];
number = 0;
court <<"input the number of array:";
cin>> n;
for (i = 0; i <n; i + +) {
court <<"input data to" <<i +1 <<":";
cin>> data [i];
sum = sum + data [i];}
average = sum / n;
court <<"\ nJumlah the" <<i <<"data above is:" <<number;
court <<"\ nRata mean the" <<i <<"data above is:" <<average;
getch ();
}
# include <conio.h>
int main () {
int i, n;
float average, number;
int data [10];
number = 0;
court <<"input the number of array:";
cin>> n;
for (i = 0; i <n; i + +) {
court <<"input data to" <<i +1 <<":";
cin>> data [i];
sum = sum + data [i];}
average = sum / n;
court <<"\ nJumlah the" <<i <<"data above is:" <<number;
court <<"\ nRata mean the" <<i <<"data above is:" <<average;
getch ();
}
Tidak ada komentar:
Posting Komentar