SlideShare a Scribd company logo
1 of 19
Array in C Language
Group : 5
Name ID Program
1. Mosana Aunuj Nasim 151-15-342 C.S,E
2. Abir Kumar Datta 153-15-618 C.S.E
3.Shah Samrat Fahim 153-15-629 C.S.E
4. Tanveer Wahid C.S.E
What Is Array ??
What Is Array ??
• Collection Of same type of data.
• Data Type ( Int, float, double, char).
• Saves data in a sequence.
• Examples:
– 1. Employees Info of an organization.
– 2. Score of students of a class.
– 3. Table of daily rainfall data.
– 4. Temperature record of hours.
Why need to use array type?
Consider the following issue:
"We have a list of 1000 students' marks of an integer
type. If using the basic data type (int), we will declare
something like the following…"
int studMark0, studMark1, studMark2, ..., studMark999;
 Can you imagine how long we have to write the
declaration part by using normal variable declaration?
– int main(void)
– {
• int studMark1, studMark2, studMark3, studMark4,
…, …, studMark998, stuMark999, studMark1000;
• …
• …
• return 0;
– }
ARRAYS
 By using an array, we just declare like this,
int studMark[1000];
This will reserve 1000 contiguous memory locations for storing the students’ marks.
Graphically, this can be depicted as in the following figure.
Examples Using Arrays
Initializers :
int n[ 5 ] = { 1, 2, 3, 4, 5 };
– If not enough initializers, rightmost elements become 0
int n[ 5 ] = { 0 }
• All elements 0
– If too many a syntax error is produced syntax error
– C arrays have no bounds checking
If size omitted, initializers determine it
int n[ ] = { 1, 2, 3, 4, 5 };
– 5 initializers, therefore 5 element array
1 /* Fig.01: fig01.c
2 Histogram printing program */
3 #include <stdio.h>
4 #define SIZE 10
5
6 int main()
7 {
8 int n[ SIZE ] = { 19, 3, 15, 7, 11, 9, 13, 5, 17, 1 };
9 int i, j;
10
11 printf( "%s%13s%17sn", "Element", "Value", "Histogram"
);12
13 for ( i = 0; i <= SIZE - 1; i++ ) {
14 printf( "%7d%13d ", i, n[ i ]) ;
15
16 for ( j = 1; j <= n[ i ]; j++ ) /* print one bar
*/17 printf( "%c", '*' );
18
19 printf( "n" );
20 }
21
22 return 0;
23 }
Output
Element Value Histogram
0 19 *******************
1 3 ***
2 15 ***************
3 7 *******
4 11 ***********
5 9 *********
6 13 *************
7 5 *****
8 17 *****************
9 1 *
Types Of Array
Three Types Of Array
– One Dimensional Array(1-D)
– Two Dimensional Array(2-D)
– Multi Dimensional Array(A[s1][s2[s3][s4]…)
One Dimensional Array(1-D)
– Initialization:
– Type Array_name [Size];
– Type Array_name [Size] = {list of Values};
 Example:
int A[10];
int A[5] ={50,60,70,80,90};
 User Define:
 int A[n]; [Size of Array declare by User.]
Two Dimensional Array(2-D)
• Initialization:
– Type Array_name[row_size][column_size];
– Type Array_name[row_size][column_size]={{s1},{s2},{s3}};
• Here s1,s2,s3 refers to sets of number.
Example:
int A[3][3] ;
int A[3][3] = {{10,20,45},{42,79,81},{89,9,36}};
User Define:
int A[r][n];
 Value of {r,n} given by
Multi Dimensional Array
Initialization:
– Type Array_name[s1][s2][s3]…..[sm];
Example:
 int survey [3][5][3];
 float table [5][4][5][3];
 Pros & Cons:
 Two dimensional array often
consider as multi dimensional array.
 Multi dimensional array is derived
from basic C Language.
Multi
Dimensional array
Example
Insertion In an Array
One Dimensional Array(1-D):
– Loops runs from 0 to n-1 th index.
– Sorting might involve if data was ask in sorting mode.
How 1-D array insertion Works:
For 0 to n-1
{input value;(Using scanf)}
int A[5
Insertion In An Array
Two Dimensional Array(2 - D):
– Loops runs
for 0 to row – 1
{for 0 to column – 1
input value;(scanf) }
How It works:
int A[3][4];
Step 1 Step 2 Step 3
Deletion In an Array
One Dimensional Array(1-D):
User given input.
Search for data
 Runs in the loops looking for the given input.
2 Condition: Found or Not found
Found condition:
Example: search: 4 (Found if available).
 Not Found (Print Not Found)
ORIGIN (Array) After Deletion
Deletion In an Array
Two Dimensional Array(2D)
User Given Input(search: 12)
 Process:
 Runs inside the loops looking for element.
Condition:
If found delete the input value and replace by ‘0’
Else print not found.
Example: Before After
Abir ppt3
Abir ppt3

More Related Content

What's hot

Data Structure Midterm Lesson Arrays
Data Structure Midterm Lesson ArraysData Structure Midterm Lesson Arrays
Data Structure Midterm Lesson Arrays
Maulen Bale
 

What's hot (20)

Arrays in c
Arrays in cArrays in c
Arrays in c
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Basic array in c programming
Basic array in c programmingBasic array in c programming
Basic array in c programming
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
 
Two dimensional arrays
Two dimensional arraysTwo dimensional arrays
Two dimensional arrays
 
Array
ArrayArray
Array
 
2D Array
2D Array 2D Array
2D Array
 
concept of Array, 1D & 2D array
concept of Array, 1D & 2D arrayconcept of Array, 1D & 2D array
concept of Array, 1D & 2D array
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
 
Array in c
Array in cArray in c
Array in c
 
Data Structure Midterm Lesson Arrays
Data Structure Midterm Lesson ArraysData Structure Midterm Lesson Arrays
Data Structure Midterm Lesson Arrays
 
Arrays In C
Arrays In CArrays In C
Arrays In C
 
One dimensional 2
One dimensional 2One dimensional 2
One dimensional 2
 
Arrays and Pointers
Arrays and PointersArrays and Pointers
Arrays and Pointers
 
Arrays 1D and 2D , and multi dimensional
Arrays 1D and 2D , and multi dimensional Arrays 1D and 2D , and multi dimensional
Arrays 1D and 2D , and multi dimensional
 
Arraysincv109102017 180831194256
Arraysincv109102017 180831194256Arraysincv109102017 180831194256
Arraysincv109102017 180831194256
 
SPL 10 | One Dimensional Array in C
SPL 10 | One Dimensional Array in CSPL 10 | One Dimensional Array in C
SPL 10 | One Dimensional Array in C
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
C++ lecture 04
C++ lecture 04C++ lecture 04
C++ lecture 04
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
 

Similar to Abir ppt3

Array.pptx
Array.pptxArray.pptx

Similar to Abir ppt3 (20)

Arrays basics
Arrays basicsArrays basics
Arrays basics
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
 
Array,MULTI ARRAY, IN C
Array,MULTI ARRAY, IN CArray,MULTI ARRAY, IN C
Array,MULTI ARRAY, IN C
 
Array.pptx
Array.pptxArray.pptx
Array.pptx
 
Array
ArrayArray
Array
 
Array in C.pdf
Array in C.pdfArray in C.pdf
Array in C.pdf
 
Array.pdf
Array.pdfArray.pdf
Array.pdf
 
CP Handout#9
CP Handout#9CP Handout#9
CP Handout#9
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
 
L5 array
L5 arrayL5 array
L5 array
 
Arrays 06.ppt
Arrays 06.pptArrays 06.ppt
Arrays 06.ppt
 
arrays
arraysarrays
arrays
 
C (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptxC (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptx
 
Array i imp
Array  i impArray  i imp
Array i imp
 
ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
 
Array
ArrayArray
Array
 
Unit4 Slides
Unit4 SlidesUnit4 Slides
Unit4 Slides
 
Array
ArrayArray
Array
 
Arrays
ArraysArrays
Arrays
 
COM1407: Arrays
COM1407: ArraysCOM1407: Arrays
COM1407: Arrays
 

Recently uploaded

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf22-prompt engineering noted slide shown.pdf
22-prompt engineering noted slide shown.pdf
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 

Abir ppt3

  • 1. Array in C Language
  • 2. Group : 5 Name ID Program 1. Mosana Aunuj Nasim 151-15-342 C.S,E 2. Abir Kumar Datta 153-15-618 C.S.E 3.Shah Samrat Fahim 153-15-629 C.S.E 4. Tanveer Wahid C.S.E
  • 4. What Is Array ?? • Collection Of same type of data. • Data Type ( Int, float, double, char). • Saves data in a sequence. • Examples: – 1. Employees Info of an organization. – 2. Score of students of a class. – 3. Table of daily rainfall data. – 4. Temperature record of hours.
  • 5. Why need to use array type? Consider the following issue: "We have a list of 1000 students' marks of an integer type. If using the basic data type (int), we will declare something like the following…" int studMark0, studMark1, studMark2, ..., studMark999;  Can you imagine how long we have to write the declaration part by using normal variable declaration? – int main(void) – { • int studMark1, studMark2, studMark3, studMark4, …, …, studMark998, stuMark999, studMark1000; • … • … • return 0; – }
  • 6. ARRAYS  By using an array, we just declare like this, int studMark[1000]; This will reserve 1000 contiguous memory locations for storing the students’ marks. Graphically, this can be depicted as in the following figure.
  • 7. Examples Using Arrays Initializers : int n[ 5 ] = { 1, 2, 3, 4, 5 }; – If not enough initializers, rightmost elements become 0 int n[ 5 ] = { 0 } • All elements 0 – If too many a syntax error is produced syntax error – C arrays have no bounds checking If size omitted, initializers determine it int n[ ] = { 1, 2, 3, 4, 5 }; – 5 initializers, therefore 5 element array
  • 8. 1 /* Fig.01: fig01.c 2 Histogram printing program */ 3 #include <stdio.h> 4 #define SIZE 10 5 6 int main() 7 { 8 int n[ SIZE ] = { 19, 3, 15, 7, 11, 9, 13, 5, 17, 1 }; 9 int i, j; 10 11 printf( "%s%13s%17sn", "Element", "Value", "Histogram" );12 13 for ( i = 0; i <= SIZE - 1; i++ ) { 14 printf( "%7d%13d ", i, n[ i ]) ; 15 16 for ( j = 1; j <= n[ i ]; j++ ) /* print one bar */17 printf( "%c", '*' ); 18 19 printf( "n" ); 20 } 21 22 return 0; 23 }
  • 9. Output Element Value Histogram 0 19 ******************* 1 3 *** 2 15 *************** 3 7 ******* 4 11 *********** 5 9 ********* 6 13 ************* 7 5 ***** 8 17 ***************** 9 1 *
  • 10. Types Of Array Three Types Of Array – One Dimensional Array(1-D) – Two Dimensional Array(2-D) – Multi Dimensional Array(A[s1][s2[s3][s4]…)
  • 11. One Dimensional Array(1-D) – Initialization: – Type Array_name [Size]; – Type Array_name [Size] = {list of Values};  Example: int A[10]; int A[5] ={50,60,70,80,90};  User Define:  int A[n]; [Size of Array declare by User.]
  • 12. Two Dimensional Array(2-D) • Initialization: – Type Array_name[row_size][column_size]; – Type Array_name[row_size][column_size]={{s1},{s2},{s3}}; • Here s1,s2,s3 refers to sets of number. Example: int A[3][3] ; int A[3][3] = {{10,20,45},{42,79,81},{89,9,36}}; User Define: int A[r][n];  Value of {r,n} given by
  • 13. Multi Dimensional Array Initialization: – Type Array_name[s1][s2][s3]…..[sm]; Example:  int survey [3][5][3];  float table [5][4][5][3];  Pros & Cons:  Two dimensional array often consider as multi dimensional array.  Multi dimensional array is derived from basic C Language. Multi Dimensional array Example
  • 14. Insertion In an Array One Dimensional Array(1-D): – Loops runs from 0 to n-1 th index. – Sorting might involve if data was ask in sorting mode. How 1-D array insertion Works: For 0 to n-1 {input value;(Using scanf)} int A[5
  • 15. Insertion In An Array Two Dimensional Array(2 - D): – Loops runs for 0 to row – 1 {for 0 to column – 1 input value;(scanf) } How It works: int A[3][4]; Step 1 Step 2 Step 3
  • 16. Deletion In an Array One Dimensional Array(1-D): User given input. Search for data  Runs in the loops looking for the given input. 2 Condition: Found or Not found Found condition: Example: search: 4 (Found if available).  Not Found (Print Not Found) ORIGIN (Array) After Deletion
  • 17. Deletion In an Array Two Dimensional Array(2D) User Given Input(search: 12)  Process:  Runs inside the loops looking for element. Condition: If found delete the input value and replace by ‘0’ Else print not found. Example: Before After