Professional Documents
Culture Documents
Lecture07 Arrays
Lecture07 Arrays
LECTURE 07
CCC101 - Introduction to Programming 1
Jennifer Joyce M. Montemayor
Solution 1
. . .
double x[8];
float prices[3];
prices[0] = 1.2;
prices[1] = 2.3;
prices[2] = 3.4;
Solution 2
int i, numbers[10];
#define N 10
int i, numbers[N];
#include<stdio.h>
int main(){
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
return 0;
}
int i;
for(i=0;i<n;i++)
list[i] = value;
int main(){
int i, size=5,
y[size], value=1;
for(i=0;i<size;i++)
printf("%d ",y[i]);
return 0;
}
16 Jennifer Joyce M. Montemayor / CCC101 / Lecture 07
Array as Formal Parameters
Two-Dimensional Array
‣ we will use to represent tables of data, matrices and other two-dimensional objects
Syntax
Example
double table[ROW_SIZE][COLUMN_SIZE];
void process_matrix(int in[][4], int out[][4], int row_count);
‣ the size of the rst dimension is the only size that can be omitted
‣ multidimensional arrays are initiialized by listing values that are grouped by row