Skip to Main Content
Introduction to Computational Modeling Using C and Open-Source Tools
book

Introduction to Computational Modeling Using C and Open-Source Tools

by Jose M. Garrido
November 2013
Intermediate to advanced content levelIntermediate to advanced
461 pages
12h 1m
English
CRC Press
Content preview from Introduction to Computational Modeling Using C and Open-Source Tools
Arrays 109
double x[10];
double w[10];
double z[2][10];
const int N = 5;
m = arraycol(x, 2.0, 11.0, 2.0);
m = arraycol(w, 1.0, 9.0, 2.0);
for(j = 0; j < N; j++) {
z[0][j] = x[i];
z[1][j] = w[i];
}
To access individual elements of a two dimensional array, two indexes are used.
The first number is the index for rows and the second number is the index for
columns. To access the value of the element in array z defined previously at row
1 and column 3, the syntax is: z[1][3]. For example:
zz = z[1][3] + 13.5;
The following lines of C code declare a two-dimensional array named rainf with
size 3 rows and 6 columns, and assign the value 2.4 to every element of the array.
const int COLS = 6;
const int ROWS = 3;
double rainf[ROWS][COLS];
for (j = 1; j < COLS; j++)
for (i
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Computer Fundamentals and Programming in C (RMK)

Computer Fundamentals and Programming in C (RMK)

Anita Goel, Ajay Mittal

Publisher Resources

ISBN: 9781482216783