SlideShare a Scribd company logo
PPt. on An _Array in C
Array ….?
Need of an Array.
 Classification of an Array.
Declaration.
Access Array Elements.
 Initialize an Array.
 An array is a data structure, which can store
a fixed-size collection of elements of the
same data type.
 All these elements are stored in consecutive
memory locations.
 May be of type int,float,char ,double and so
on….
 The size should be an individual constant.
 C arrays are always indexed from 0.
* We can use normal variables (v1, v2, v3, ..)
when we have a small number of objects, but
if we want to store a large number of
instances, it becomes difficult to manage
them with normal variables. The idea of an
array is to represent many instances in one
variable.
* We will learn the need of an array with the
program . Program is at 9th and 10th slide.
 Single / One Dimensional Array (1-D Array):-
 Multi Dimensional Array:-
# Single Dimensional Array #
single dimensional arrays are used to store a row of
values. In single dimensional array, data is stored in
linear form. Single dimensional arrays are also called
as One-dimensional Arrays, Linear Arrays or simply
1-D Arrays.
 Datatype arrayName[arraySize];
 For example:-
Here, we declared an array, , of
floating-point type. And its size is 5.
Meaning, it can hold 5 floating-point values.
 It's important to note that the size and type
of an array cannot be changed once it is
declared.
float mark[5];
mark
 You can access elements of an array by
indices.
 Suppose you declared an array as
above. The first element is , the
second element is and so on.
mark
mark[0]
mark[1]
Few Keynotes:-
• Arrays have 0 as the first index, not 1. In this
example, is the first element.
• If the size of an array is , to access the last
element, the index is used. In this example,
• Suppose the starting addressing of is 2530d.
Then, the address of the will be 2534d.
Similarly, the address of will be 2538d. And
so on ….. This is because the size of a float is 4 bytes.
mark[0]
n
n-1 mark[4]
mark[0]
Mark[1]
Mark[2]
 It is possible to initialize an array during declaration.
For example,
 You can also initialize an array like this.
 Here, we haven't specified the size. However, the
compiler knows its size is 5 as we are initializing it
with 5 elements.
mark[0] mark[1] mark[2] mark[3] mark[4]
Here,
int mark[5] = {5, 17, 22, 15, 8};
int mark[] = {5, 17, 22, 15, 8};
5 17 22 15 8
mark[0] is equal to: 5
mark[1] is equal to: 17
mark[2] is equal to: 22
mark[3] is equal to: 15
mark[4] is equal to: 8
Que:- Program to take 5 values from the user and store
them. And print the stored element. Without using array.
#include <stdio.h>
int main()
{
int a,b,c,d,e;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c
scanf("%d",&d);
scanf("%d",&e);
printf("%dn",a);
printf("%dn",b);
printf("%dn",c);
printf("%dn",d);
printf("%dn",e);
return 0;
}
Output
1
8
34
0
3
1
8
34
0
3
Que:- Program to take 5 values from the user and store
them in an array. And print the stored element.
#include <stdio.h>
int main() {
int values[5];
printf("Enter 5 integers: ");
// taking input and storing it in an array
for(int i = 0; i < 5; ++i) {
scanf("%d", &values[i]);
}
printf("Displaying integers: ");
// printing elements of an array
for(int i = 0; i < 5; ++i) {
printf("%dn", values[i]);
}
return 0;
}
Output
Enter 5 integers: 1
8
34
0
3
Displaying integers: 1
8
34
0
3
PPt. on An _Array in C

More Related Content

PPT
Numeric Arrays [6]
ODP
C++ arrays part1
PPTX
Arrays accessing using for loops
PPT
Presentation of array
PPTX
Presentation on array
PPTX
Array in c programming
PPT
Arrays Basics
Numeric Arrays [6]
C++ arrays part1
Arrays accessing using for loops
Presentation of array
Presentation on array
Array in c programming
Arrays Basics

What's hot (20)

PDF
Arrays in C++
PPTX
Java arrays
PPTX
PPTX
PPTX
Array in Java
PPTX
Arrays in C++
PPT
PPTX
Types of Arrays
PPTX
arrays of structures
PPTX
Arrays in java
PPTX
Arrays
PDF
Arrays in Java
PPTX
Array in c programming
PPTX
Array Of Pointers
PPT
Array
PPT
Mesics lecture 8 arrays in 'c'
PPTX
arrays in c
PDF
Arrays in C++
Java arrays
Array in Java
Arrays in C++
Types of Arrays
arrays of structures
Arrays in java
Arrays
Arrays in Java
Array in c programming
Array Of Pointers
Array
Mesics lecture 8 arrays in 'c'
arrays in c
Ad

Similar to PPt. on An _Array in C (20)

PPTX
Arrays.pptx
PPTX
INDIAN INSTITUTE OF TECHNOLOGY KANPUR ESC 111M Lec12.pptx
PDF
[ITP - Lecture 15] Arrays & its Types
PDF
arraysfor engineering students sdf ppt on arrays
PPTX
array ppt of c programing language for exam
PPTX
Chapter 13.pptx
PDF
Array and its types and it's implemented programming Final.pdf
PDF
Array&amp;string
PPTX
Programming in c Arrays
PDF
PPT
Lecture 15 Arrays with C++ programming.ppt
PPTX
Arrays basics
PPTX
COM1407: Arrays
PPT
Array THE DATA STRUCTURE. ITS THE STRUCT
PPT
Arrays
PPTX
PPTX
Module_3_Arrays - Updated.pptx............
PPTX
Array ppt you can learn in very few slides.
PPT
Array
Arrays.pptx
INDIAN INSTITUTE OF TECHNOLOGY KANPUR ESC 111M Lec12.pptx
[ITP - Lecture 15] Arrays & its Types
arraysfor engineering students sdf ppt on arrays
array ppt of c programing language for exam
Chapter 13.pptx
Array and its types and it's implemented programming Final.pdf
Array&amp;string
Programming in c Arrays
Lecture 15 Arrays with C++ programming.ppt
Arrays basics
COM1407: Arrays
Array THE DATA STRUCTURE. ITS THE STRUCT
Arrays
Module_3_Arrays - Updated.pptx............
Array ppt you can learn in very few slides.
Array
Ad

Recently uploaded (20)

PPTX
Glazing at Facade, functions, types of glazing
PDF
Top 10 read articles In Managing Information Technology.pdf
PDF
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
PDF
Introduction to Data Science: data science process
PPT
High Data Link Control Protocol in Data Link Layer
PDF
6th International Conference on Artificial Intelligence and Machine Learning ...
PPTX
ANIMAL INTERVENTION WARNING SYSTEM (4).pptx
PDF
BRKDCN-2613.pdf Cisco AI DC NVIDIA presentation
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PDF
Chad Ayach - A Versatile Aerospace Professional
PDF
B.Tech (Electrical Engineering ) 2024 syllabus.pdf
PPT
Ppt for engineering students application on field effect
PPT
SCOPE_~1- technology of green house and poyhouse
PDF
July 2025: Top 10 Read Articles Advanced Information Technology
PPTX
Internship_Presentation_Final engineering.pptx
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
24AI201_AI_Unit_4 (1).pptx Artificial intelligence
PDF
Geotechnical Engineering, Soil mechanics- Soil Testing.pdf
PDF
Monitoring Global Terrestrial Surface Water Height using Remote Sensing - ARS...
Glazing at Facade, functions, types of glazing
Top 10 read articles In Managing Information Technology.pdf
Traditional Exams vs Continuous Assessment in Boarding Schools.pdf
Introduction to Data Science: data science process
High Data Link Control Protocol in Data Link Layer
6th International Conference on Artificial Intelligence and Machine Learning ...
ANIMAL INTERVENTION WARNING SYSTEM (4).pptx
BRKDCN-2613.pdf Cisco AI DC NVIDIA presentation
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Chad Ayach - A Versatile Aerospace Professional
B.Tech (Electrical Engineering ) 2024 syllabus.pdf
Ppt for engineering students application on field effect
SCOPE_~1- technology of green house and poyhouse
July 2025: Top 10 Read Articles Advanced Information Technology
Internship_Presentation_Final engineering.pptx
Lesson 3_Tessellation.pptx finite Mathematics
24AI201_AI_Unit_4 (1).pptx Artificial intelligence
Geotechnical Engineering, Soil mechanics- Soil Testing.pdf
Monitoring Global Terrestrial Surface Water Height using Remote Sensing - ARS...

PPt. on An _Array in C

  • 2. Array ….? Need of an Array.  Classification of an Array. Declaration. Access Array Elements.  Initialize an Array.
  • 3.  An array is a data structure, which can store a fixed-size collection of elements of the same data type.  All these elements are stored in consecutive memory locations.  May be of type int,float,char ,double and so on….  The size should be an individual constant.  C arrays are always indexed from 0.
  • 4. * We can use normal variables (v1, v2, v3, ..) when we have a small number of objects, but if we want to store a large number of instances, it becomes difficult to manage them with normal variables. The idea of an array is to represent many instances in one variable. * We will learn the need of an array with the program . Program is at 9th and 10th slide.
  • 5.  Single / One Dimensional Array (1-D Array):-  Multi Dimensional Array:- # Single Dimensional Array # single dimensional arrays are used to store a row of values. In single dimensional array, data is stored in linear form. Single dimensional arrays are also called as One-dimensional Arrays, Linear Arrays or simply 1-D Arrays.
  • 6.  Datatype arrayName[arraySize];  For example:- Here, we declared an array, , of floating-point type. And its size is 5. Meaning, it can hold 5 floating-point values.  It's important to note that the size and type of an array cannot be changed once it is declared. float mark[5]; mark
  • 7.  You can access elements of an array by indices.  Suppose you declared an array as above. The first element is , the second element is and so on. mark mark[0] mark[1]
  • 8. Few Keynotes:- • Arrays have 0 as the first index, not 1. In this example, is the first element. • If the size of an array is , to access the last element, the index is used. In this example, • Suppose the starting addressing of is 2530d. Then, the address of the will be 2534d. Similarly, the address of will be 2538d. And so on ….. This is because the size of a float is 4 bytes. mark[0] n n-1 mark[4] mark[0] Mark[1] Mark[2]
  • 9.  It is possible to initialize an array during declaration. For example,  You can also initialize an array like this.  Here, we haven't specified the size. However, the compiler knows its size is 5 as we are initializing it with 5 elements. mark[0] mark[1] mark[2] mark[3] mark[4] Here, int mark[5] = {5, 17, 22, 15, 8}; int mark[] = {5, 17, 22, 15, 8}; 5 17 22 15 8 mark[0] is equal to: 5 mark[1] is equal to: 17 mark[2] is equal to: 22 mark[3] is equal to: 15 mark[4] is equal to: 8
  • 10. Que:- Program to take 5 values from the user and store them. And print the stored element. Without using array. #include <stdio.h> int main() { int a,b,c,d,e; scanf("%d",&a); scanf("%d",&b); scanf("%d",&c scanf("%d",&d); scanf("%d",&e); printf("%dn",a); printf("%dn",b); printf("%dn",c); printf("%dn",d); printf("%dn",e); return 0; } Output 1 8 34 0 3 1 8 34 0 3
  • 11. Que:- Program to take 5 values from the user and store them in an array. And print the stored element. #include <stdio.h> int main() { int values[5]; printf("Enter 5 integers: "); // taking input and storing it in an array for(int i = 0; i < 5; ++i) { scanf("%d", &values[i]); } printf("Displaying integers: "); // printing elements of an array for(int i = 0; i < 5; ++i) { printf("%dn", values[i]); } return 0; } Output Enter 5 integers: 1 8 34 0 3 Displaying integers: 1 8 34 0 3