


























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



























































FE – C Programming
Assistant Professor
Dept. of Computer Engineering,
SIES Graduate School of Technology
Objectives :To provide exposure to problem-solving by developing an
algorithm, flowchart and implement the logic using C programming
language
Outcomes: Learner will be able to …
language.
Namrata Jiten Patel
Learning Outcomes
element,representation of array element in memory and other
possible operations.
element,representation of array element in memory and other
possible operations
other operations.
Namrata Jiten Patel
Introduction
each variable can only be used to store a single value at a time. For
example, each of the variables ch, n, and price declared in the
statements.
These kind of variable holds different data types, and each variable
can only store one value of the declared data type.
These types of variables are called scalar variables.
A scalar variable is a single variable whose stored value is an atomic
type. This means that the value cannot be further subdivided or
separated into a legitimate data type.
Namrata Jiten Patel
Define Array
manipulation of potentially huge quantities of data.
Homogeneous means that all the values are of the same data type.
2, 3, 4} is different from {1, 4, 3, 2}
Namrata Jiten Patel
Ordered—one can count off the elements 0, 1, 2, 3, ...
Fixed in size
Homogeneous—all elements must be of the same type, e.g., int, float, char,
etc.
the size.
index begins at zero and is always written inside square brackets.
Namrata Jiten Patel
One-Dimensional array
identifier with a bracketed constant integral expression
array.
(size –1). Thus, the following relationships hold.
Namrata Jiten Patel
Illustrating the organization of number array in memory
with the correct designation for each array element.
Namrata Jiten Patel 11
Array Declarations
Namrata Jiten Patel
Initializing the array
Namrata Jiten Patel
Automatic sizing While initializing, the size of a one-dimensional array can be
omitted as shown.
int arr[] = {3,1,5,7,9};
Here, the C compiler will deduce the size of the array from the initialization
statement. From the above initialization statement, the size of the array is
deduced to be 5.
Basic example
index++)
Namrata Jiten Patel 16
‘slot’ in that block.
That is, arrays are allocated contiguous space in memory and so they are closely related to the
notion of pointer which will be discussed later.”
compiler allocates sizeof(X) bytes to hold it.
stored at the memory location starting with byte
of array).
Namrata Jiten Patel
References to elements outside of
the array bounds
references to array elements lie within the declared bounds of the
associated arrays
Namrata Jiten Patel
Glimpse of memory allocation
memory, which is known as the stack, is used by variables in the
program
Namrata Jiten Patel