0% found this document useful (0 votes)
3 views12 pages

Understanding Arrays in C Programming

Basics of arrays
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views12 pages

Understanding Arrays in C Programming

Basics of arrays
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Computer Programming

(FCCS002 )
Semester 1, Section 2
UNIT-II Arrays and
Pointers
Topic: Arrays
Arrays: Introduction
main( )
{
int x ;
x=5;
x = 10 ;

printf ( "\n x = %d", x ) ;


}
• per = { 48, 88, 34, 23, 96 }

• Thus, an array is a collection of similar elements.


• These similar elements could be all ints, or all floats, or all chars, etc.
A Simple Program Using Array
Array Declaration
• type var_name[size];
• int marks[30] ;
• double balance[100];

• The amount of storage required to hold an array is directly related to its


type and size.
• For a single dimension array, the total size in bytes is computed as shown
here:
• total bytes = sizeof(base type) ×length of array
Accessing Elements of an Array
• Entering Data into an Array
• Reading Data from an Array
A Simple Program Using Array
Array Initialisation
Array Elements in Memory
• Consider the following array declaration:
int arr[8] ;
Bounds Checking

You might also like