This document provides information about one-dimensional arrays in C programming. It defines an array as a fixed-size collection of elements of the same data type. A one-dimensional array, also called a vector, uses one subscript to represent a list of data items. The document outlines how to declare and initialize a one-dimensional array in C, including specifying the data type, array name, and size in the declaration, and providing an initializer list of values in curly braces for initialization. Examples of declaring and initializing integer, character, and float arrays are provided.
Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.
Abstract data types (adt) intro to data structure part 2Self-Employed
Abstract Data type (ADT), Related to DATA STRUCTURE and ALGORITHMS STACK QUEUE ARRAY LINKED LIST ALGORITHMS AND INSERTION DELETION MERGE TRAVERSE MODIFY AND OTHER related operation in the algorithms of stack queue array and linked list as an ADT type
Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.
Abstract data types (adt) intro to data structure part 2Self-Employed
Abstract Data type (ADT), Related to DATA STRUCTURE and ALGORITHMS STACK QUEUE ARRAY LINKED LIST ALGORITHMS AND INSERTION DELETION MERGE TRAVERSE MODIFY AND OTHER related operation in the algorithms of stack queue array and linked list as an ADT type
This presentation contains:
About dynamic memory allocations
Methods or functions used for dynamic memory allocation
Examples of dynamic memory allocation with code
Difference between array and linked lists
Merits and demerits of linked lists
What we can achieve with linked lists?
Data structure comes with a number of algorithms. It works with different types of data and structures and organizes data to fulfill a specific purpose. It deals with algorithms, Algorithm design, Algorithm analysis, Graph algorithms, Equivalence relations, Hash functions, hash tables, Theory of computation, linked lists, stacks, queues, searching and sorting techniques, graph data structure, trees, recursion of algorithms. It is technical way of storing data by using some specific techniques in order to use data efficiently.
This presentation contains:
About dynamic memory allocations
Methods or functions used for dynamic memory allocation
Examples of dynamic memory allocation with code
Difference between array and linked lists
Merits and demerits of linked lists
What we can achieve with linked lists?
Data structure comes with a number of algorithms. It works with different types of data and structures and organizes data to fulfill a specific purpose. It deals with algorithms, Algorithm design, Algorithm analysis, Graph algorithms, Equivalence relations, Hash functions, hash tables, Theory of computation, linked lists, stacks, queues, searching and sorting techniques, graph data structure, trees, recursion of algorithms. It is technical way of storing data by using some specific techniques in order to use data efficiently.
This is a presentation on Arrays, one of the most important topics on Data Structures and algorithms. Anyone who is new to DSA or wants to have a theoretical understanding of the same can refer to it :D
Functions: Function Definition, prototyping, types of functions, passing arguments to functions, Nested Functions, Recursive functions.
Strings: Declaring and Initializing strings, Operations on strings, Arrays of strings, passing strings to functions. Storage Classes: Automatic, External, Static and Register Variables.
1. GANDHINAGAR INSTITUTE OF
TECHONOLOGY(012)
SUBJECT : Computer Programming and
Utilization(2110003)
Active Learning Assignment on the topic of
“Concepts of Arrays,
One dimensional array declaration and initialization”
BE Mechanical
Prepared By:
03-02-2018 1
2. Prepared by-
Guided by –
Gandhinagar Institute of Technology
SUBJECT: CPU (2110003)
“Concepts of Arrays,
One dimensional array declaration and initialization”
3. CONTAIN
• Introduction
• Types of Arrays
• Declaration of 1D Arrays
• Initialization of 1D Arrays
• Reference
203-02-2018
4. Introduction
3
We have used the fundamental data types, char,int, float,
double.
These types are constrained by the fact that a variable of these
types can store only one value at any given time.
In many applications, we need to handle large volumes of data.
To process such large amounts of data, we need a powerful
data types that would facilitate efficient storing, accessing and
manipulation of data items.
03-02-2018
5. Introduction
4
C supports a derived data type known as array.
An array is a fixed-size sequenced collection of
elements of the same data type.
An array can be used to represent a list of numbers, or
a list of names.
Example: List of temperatures recorded in every hour
in a day, or a month, or a year.
03-02-2018
6. Types of Arrays
5
Array can be classified as following types…
1) One Dimensional arrays
2) Two Dimensional arrays
3) Maltidimensional arrays
03-02-2018
7. One-Dimensional Arrays
6
Dimensional refers to the array’s size , which is how big the
array is.
A list of item can be given one variable name using only one
subscript and such a variable is called One Dimensional Arrays.
A one-dimensional array can be used to represent a list of data
items.
It is also known as a vector.
03-02-2018
8. Declaration of 1D Arrays
7
Every array must be declared before use like other variables.
The general form of array declaration is ….
datatype variable-name [size];
datatype refers to the data type of elements in the array. It can
be int, char, float, long int etc.
Name is an identifier which represents the array name.
Size is an integer expression representing the total number of
elements in the array.
Where,
03-02-2018
9. Declaration of 1D Arrays
8
Example:
1) int list[10];
2) char name[20];
3) float height[30];
When an array is declared, the compiler allocates a base
address and reserves enough space in memory for all
the elements of the array.
In C, the array name represents this base address.
For example: float x[5]; is the declaration of a one-
dimensional array.
03-02-2018
10. Initialization of 1D Arrays
9
An array can be initialised in its declaration only.
After an array is declared, its elements must be initialized.
Otherwise, they will contain “garbage”.
An array can be initialized at either of the following
stages:
At compile time
At run time
The general form of initilization of arrays is ….
datatype array-name [size]= {list of values};
03-02-2018
11. Initialization of 1D Arrays
10
The list of values are enclosed in bracets.
The initialisers are separated by commas and they must be
constants or constant expressions.
A semicolon should be placed after the closing bracet.
One-dimensional array can be initialised as given below:
int a[4]={3,5,-8, 10};
The values within the bracets are scanned from left end and
assigned to a[0], a[1] and so on.
The size of a one-dimensional array need not be mentioned in its
initialisation.
In this case, the compiler will count the values assigned and take it
as the size of that array.
03-02-2018