SlideShare a Scribd company logo
1 of 43
To presentation
.BCA II SEM.
SUBMITTED TO:
CHETAN SIR
SUBMITTED BY :
HINA KHAN
Prakash Khaire
The Mandvi Education Society Institute of Computer Science
A
R
R
A
Y
S
CONTENTS
 Introduction
 Need for on array
 Types of array
• 1D
• 2D
• MD
 Difference between 1D & 2D Array
 Array Applications
 Advantages & disadvantages
What is an Array ?
• It is derived data type.
• The nature of array is static (fix).
• Array is a collection of similar or
homogeneous data type.
• Array is also known subscript variable
or index variable.
• The lower bond of an array is zero 0.
• The upper bond of an array is n-1.
for ex.-int a[9] is an array that stores 9 integers
• Array index start with zero(0).
• Array end with n-1.
0 1 2 3 4 5 6 7 8
100 102 104 106 108 110 112 114 116
index
elements
Memory address
'
Need for an Array
NEED FOR AN ARRAY
• To store large number of variables of same type under a
single variable.
• E.g.
To store Marks of 50 students.
Record of sales of 100 salesman.
Types of Array
A list of items can be given one variable name using
only one subscript and such a variable is called a one-
dimensional Array.
•Syntax
data_type ArrayName[size];
data_type : is a valid data type like int, float,char
Arrayname : is a valid identifier
size : maximum number of elements that can
be stored in array
1. Declaration of on Array
To declare an array to syntax is-
Data_ type variablename [size];
o The type of data which you
want to store like – int , float
, char.
o Means the name
of an Array.
o The number of Array
type variable.
Ex.- int a [3];
• Type of array variable is “integer”.
• Its variable name is a.
• 3 is the size of the array.
2. Initialization
• An elements of an array must be initialized, otherwise they
may contain “garbage” value.
• An array can be initialized at either of the following stages
o At compile time
o At run time
• At the time of declaration and
initialization at the same time.
• For ex.- int a[5]={1,2,3,4,5}
An array can be explicitly in
initialization at run time.
• To initialize multiple array variable for loop is used.
for ex.-
for (i=0;i<5;i++)
{
scanf (“%d”,&a[i]);
}
3.Assessing
• To print the element of an array is known as
assessing.
• To assessing the element of an array for loop is
used frequently.
for ex.-
for (i=0; i<5 ;i++)
{
printf (“%d”,a[i]);
} OUTPUT:
0
1
2
3
4
Examples:-
1) Enter a one-d array
#include<stdio.h>
int main()
{
int a[10],i;
printf(“enter the array=“);
for(i=0;i<10;i++)
{
scanf(“%d”,&a[i]);
}
printf(“the entered array is=“);
for(i=0;i<10;i++)
{
printf(“%d”,a[i]);
}
return(0);
}
output:
0
1
2
3
4
5
6
7
8
9
• C allows us to define such tables of items by using
two-dimensional arrays.
•The two dimensional array are declared as follows-
type array_name[row_size][column_size];
For ex.- int a [3][2];
Data type
Array name Row=3
Column=2
1. Declaration 2D ARRAY
• To declare an array to syntax is.
• The syntax of 2D array is
datatype arrayname[row] [column];
2.Initializing 2D ARRAY
• Like 1D array ,2D array initialized.
• Tow for loop is used .
ex.-
for (i=0 ;i<3; i++)
{
for (j=0;j<3;j++)
{
scanf(“%d”,&a[i][j]);
}
}
3.Assessing 2D ARRAY
• For loop is used.
Ex.-
for (i=0; i<3; i++)
{
for(j=0; j<3;j++)
{
printf(“t%d”,a[i][j]);
}
print(“n”);
}
• To print the element of an array
is known as assessing.
/* addition of two matrix/*
#include<stdio.h>
int main()
{
int i,j;
int a[3][3],b[3][3],c[3][3];
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“enter the matrix a=”);
scanf(“%d”,&a[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“enter the matrix b=”);
scanf(“%d”,&b[i][j]);
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
Printf(“/n addition of two matrix=“);
{
for(i=0;i<3;i++)
{
for(J=0;j<3;j++)
{
printf(“%d”,c[i][j]);
}
printf(“/n”);
}
}
return(0);
}
output:
A= B=
C=
9 8 7
6 5 4
3 2 1
1 2 3
4 5 6
7 8 9
10 10 10
10 10 10
10 10 10
/*subtraction of two matrix/*
#include<stdio.h>
int main()
{
int i,j;
int a[3][3],b[3][3],c[3][3];
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“enter the matrix a=”);
scanf(“%d”,&a[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“enter the matrix b=”);
scanf(“%d”,&b[i][j]);
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=a[i][j]-b[i][j];
}
}
Printf(“/n substract of two matrix=”);
{
for(i=0;i<3;i++)
{
for(J=0;j<3;j++)
{
printf(“%d”,c[i][j]);
}
printf(“/n”);
}
}
return(0);
}
output:
A= B=
C=
2 3 4
5 6 7
8 9 10
1 2 3
4 5 6
7 8 9
1 1 1
1 1 1
1 1 1
/*multiplication of two matrix/*
#include<stdio.h>
int main()
{
int i,j,k;
int a[3][3],b[3][3],c[3][3];
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“enter the matrix a=”);
scanf(“%d”,&a[i][j]);
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“enter the matrix b=”);
scanf(“%d”,&b[i][j]);
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=0;
for(k=0;k<3;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
printf(“n enter the matix a is =”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“t%d”,c[i][j]);
}
printf(“n”);
}
printf(“n enter the matrix b is =”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“t%d”,b[i][j]);
}
printf(“n”);
}
printf(“n the multiplication is =”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“t%d”,c[i][j]);
}
printf(“n”);
}
return(0);
}
output:
A=
B=
AB=
1 2 3
4 5 6
7 8 9
9 8 7
6 5 4
3 2 1
46 28 10
118 73 28
190 118 46
Not in courseNot in
course
• C allows arrays of three or more dimensions. The exact limit
is determined by the compiler
•Syntax-
Datatype aray_name[s1][s2][s3]………….[Sm];
• For ex-
int MyArray[2][3][4];
DIFFERENCE
1D
1. 1D Array contains
single row and
multiple columns.
2. 1D Array is a
simple collection
of elements.
3. Ex:-
2d
1. 2D Array contains
multiple row and
multiple columns.
2. 2D Array is a
collection of 1D
Array .
3. Ex:-
1 2 3 4 1 2 3 4
A 1 2 3
B 4 5 6
C 7 8 9
Array Applications
Array Applications
• Array can be used for sorting elements.
• Array can perform matrix operation.
• Array can be used to sum all the
elements.
• Array can be stores elements of same
data type.
• Given a list of test scores, determine the maximum
and minimum scores.
• Read in a list of student names and rearrange
them in alphabetical order (sorting).
• Given the height measurements of students in a
class, output the names of those students who are
taller than average.
Advantages
&
Disadvantages
Advantages
 It is used to represent multiple data of same type by assigning only
single name.
 It can be used to implement other data structures like –
linked lists , stacks ,queue etc….
 2D array are used to represent matrices.
Disadvantages
 We must know array is static structure It means that array is fixed size. The
memory which is allocated to array can not be increased or reduced.
 Since array is of fixed size , if we allocate more memory than requirement then the
memory space will be wasted . And if we allocate less memory than requirement
than it will create problem.
 The elements of array are stored in consecutive memory location. So insertions
and deletion are very difficult and time consuming.
 Programming in ANSI
(E balagurusamy)
 Thank you Chetan Sir for giving me this topic
I would like to thank my friends who
helped meEkta, Sakina, Kunal
Array 2 hina
Array 2 hina

More Related Content

What's hot (20)

Presentation on array
Presentation on array Presentation on array
Presentation on array
 
Lecture 2a arrays
Lecture 2a arraysLecture 2a arrays
Lecture 2a arrays
 
C++ arrays part1
C++ arrays part1C++ arrays part1
C++ arrays part1
 
String
StringString
String
 
Arrays
ArraysArrays
Arrays
 
arrays in c
arrays in carrays in c
arrays in c
 
Array
ArrayArray
Array
 
Array in Java
Array in JavaArray in Java
Array in Java
 
ARRAY
ARRAYARRAY
ARRAY
 
Arrays in c language
Arrays in c languageArrays in c language
Arrays in c language
 
Arrays
ArraysArrays
Arrays
 
Java arrays
Java arraysJava arrays
Java arrays
 
Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
 
Array
ArrayArray
Array
 
OOPs with java
OOPs with javaOOPs with java
OOPs with java
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
 
arrays of structures
arrays of structuresarrays of structures
arrays of structures
 
Arrays In C
Arrays In CArrays In C
Arrays In C
 
Lecture 3 data structures and algorithms
Lecture 3 data structures and algorithmsLecture 3 data structures and algorithms
Lecture 3 data structures and algorithms
 
Data structures
Data structuresData structures
Data structures
 

Similar to Array 2 hina (20)

Array
ArrayArray
Array
 
Mesics lecture 8 arrays in 'c'
Mesics lecture 8   arrays in 'c'Mesics lecture 8   arrays in 'c'
Mesics lecture 8 arrays in 'c'
 
data structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptxdata structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptx
 
ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
 
2 Arrays & Strings.pptx
2 Arrays & Strings.pptx2 Arrays & Strings.pptx
2 Arrays & Strings.pptx
 
Arrays
ArraysArrays
Arrays
 
UNIT-5_Array in c_part1.pptx
UNIT-5_Array in c_part1.pptxUNIT-5_Array in c_part1.pptx
UNIT-5_Array in c_part1.pptx
 
arrays.docx
arrays.docxarrays.docx
arrays.docx
 
Unit 2 linear data structures
Unit 2   linear data structuresUnit 2   linear data structures
Unit 2 linear data structures
 
Arrays and Strings
Arrays and Strings Arrays and Strings
Arrays and Strings
 
Arrays
ArraysArrays
Arrays
 
Array
ArrayArray
Array
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Arrays
ArraysArrays
Arrays
 
Arrays
ArraysArrays
Arrays
 
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
 
Array
ArrayArray
Array
 
unit 2.pptx
unit 2.pptxunit 2.pptx
unit 2.pptx
 
Chapter-Five.pptx
Chapter-Five.pptxChapter-Five.pptx
Chapter-Five.pptx
 
arrayppt.pptx
arrayppt.pptxarrayppt.pptx
arrayppt.pptx
 

Recently uploaded

VIP Call Girl Cuttack Aashi 8250192130 Independent Escort Service Cuttack
VIP Call Girl Cuttack Aashi 8250192130 Independent Escort Service CuttackVIP Call Girl Cuttack Aashi 8250192130 Independent Escort Service Cuttack
VIP Call Girl Cuttack Aashi 8250192130 Independent Escort Service CuttackSuhani Kapoor
 
内布拉斯加大学林肯分校毕业证录取书( 退学 )学位证书硕士
内布拉斯加大学林肯分校毕业证录取书( 退学 )学位证书硕士内布拉斯加大学林肯分校毕业证录取书( 退学 )学位证书硕士
内布拉斯加大学林肯分校毕业证录取书( 退学 )学位证书硕士obuhobo
 
Neha +91-9537192988-Friendly Ahmedabad Call Girls has Complete Authority for ...
Neha +91-9537192988-Friendly Ahmedabad Call Girls has Complete Authority for ...Neha +91-9537192988-Friendly Ahmedabad Call Girls has Complete Authority for ...
Neha +91-9537192988-Friendly Ahmedabad Call Girls has Complete Authority for ...Niya Khan
 
VIP Call Girls in Cuttack Aarohi 8250192130 Independent Escort Service Cuttack
VIP Call Girls in Cuttack Aarohi 8250192130 Independent Escort Service CuttackVIP Call Girls in Cuttack Aarohi 8250192130 Independent Escort Service Cuttack
VIP Call Girls in Cuttack Aarohi 8250192130 Independent Escort Service CuttackSuhani Kapoor
 
VIP Call Girls Service Cuttack Aishwarya 8250192130 Independent Escort Servic...
VIP Call Girls Service Cuttack Aishwarya 8250192130 Independent Escort Servic...VIP Call Girls Service Cuttack Aishwarya 8250192130 Independent Escort Servic...
VIP Call Girls Service Cuttack Aishwarya 8250192130 Independent Escort Servic...Suhani Kapoor
 
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen Dating
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen DatingDubai Call Girls Starlet O525547819 Call Girls Dubai Showen Dating
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen Datingkojalkojal131
 
OSU毕业证留学文凭,制做办理
OSU毕业证留学文凭,制做办理OSU毕业证留学文凭,制做办理
OSU毕业证留学文凭,制做办理cowagem
 
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证obuhobo
 
Resumes, Cover Letters, and Applying Online
Resumes, Cover Letters, and Applying OnlineResumes, Cover Letters, and Applying Online
Resumes, Cover Letters, and Applying OnlineBruce Bennett
 
Dark Dubai Call Girls O525547819 Skin Call Girls Dubai
Dark Dubai Call Girls O525547819 Skin Call Girls DubaiDark Dubai Call Girls O525547819 Skin Call Girls Dubai
Dark Dubai Call Girls O525547819 Skin Call Girls Dubaikojalkojal131
 
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual serviceanilsa9823
 
VIP Call Girls Service Jamshedpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Jamshedpur Aishwarya 8250192130 Independent Escort Ser...VIP Call Girls Service Jamshedpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Jamshedpur Aishwarya 8250192130 Independent Escort Ser...Suhani Kapoor
 
Booking open Available Pune Call Girls Ambegaon Khurd 6297143586 Call Hot In...
Booking open Available Pune Call Girls Ambegaon Khurd  6297143586 Call Hot In...Booking open Available Pune Call Girls Ambegaon Khurd  6297143586 Call Hot In...
Booking open Available Pune Call Girls Ambegaon Khurd 6297143586 Call Hot In...Call Girls in Nagpur High Profile
 
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...Suhani Kapoor
 
VIP Kolkata Call Girl Lake Gardens 👉 8250192130 Available With Room
VIP Kolkata Call Girl Lake Gardens 👉 8250192130  Available With RoomVIP Kolkata Call Girl Lake Gardens 👉 8250192130  Available With Room
VIP Kolkata Call Girl Lake Gardens 👉 8250192130 Available With Roomdivyansh0kumar0
 
Final Completion Certificate of Marketing Management Internship
Final Completion Certificate of Marketing Management InternshipFinal Completion Certificate of Marketing Management Internship
Final Completion Certificate of Marketing Management InternshipSoham Mondal
 
Vip Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
Vip  Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...Vip  Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
Vip Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...shivangimorya083
 
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service BhiwandiVIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service BhiwandiSuhani Kapoor
 
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 

Recently uploaded (20)

VIP Call Girl Cuttack Aashi 8250192130 Independent Escort Service Cuttack
VIP Call Girl Cuttack Aashi 8250192130 Independent Escort Service CuttackVIP Call Girl Cuttack Aashi 8250192130 Independent Escort Service Cuttack
VIP Call Girl Cuttack Aashi 8250192130 Independent Escort Service Cuttack
 
内布拉斯加大学林肯分校毕业证录取书( 退学 )学位证书硕士
内布拉斯加大学林肯分校毕业证录取书( 退学 )学位证书硕士内布拉斯加大学林肯分校毕业证录取书( 退学 )学位证书硕士
内布拉斯加大学林肯分校毕业证录取书( 退学 )学位证书硕士
 
Neha +91-9537192988-Friendly Ahmedabad Call Girls has Complete Authority for ...
Neha +91-9537192988-Friendly Ahmedabad Call Girls has Complete Authority for ...Neha +91-9537192988-Friendly Ahmedabad Call Girls has Complete Authority for ...
Neha +91-9537192988-Friendly Ahmedabad Call Girls has Complete Authority for ...
 
VIP Call Girls in Cuttack Aarohi 8250192130 Independent Escort Service Cuttack
VIP Call Girls in Cuttack Aarohi 8250192130 Independent Escort Service CuttackVIP Call Girls in Cuttack Aarohi 8250192130 Independent Escort Service Cuttack
VIP Call Girls in Cuttack Aarohi 8250192130 Independent Escort Service Cuttack
 
VIP Call Girls Service Cuttack Aishwarya 8250192130 Independent Escort Servic...
VIP Call Girls Service Cuttack Aishwarya 8250192130 Independent Escort Servic...VIP Call Girls Service Cuttack Aishwarya 8250192130 Independent Escort Servic...
VIP Call Girls Service Cuttack Aishwarya 8250192130 Independent Escort Servic...
 
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen Dating
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen DatingDubai Call Girls Starlet O525547819 Call Girls Dubai Showen Dating
Dubai Call Girls Starlet O525547819 Call Girls Dubai Showen Dating
 
OSU毕业证留学文凭,制做办理
OSU毕业证留学文凭,制做办理OSU毕业证留学文凭,制做办理
OSU毕业证留学文凭,制做办理
 
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
 
Resumes, Cover Letters, and Applying Online
Resumes, Cover Letters, and Applying OnlineResumes, Cover Letters, and Applying Online
Resumes, Cover Letters, and Applying Online
 
Dark Dubai Call Girls O525547819 Skin Call Girls Dubai
Dark Dubai Call Girls O525547819 Skin Call Girls DubaiDark Dubai Call Girls O525547819 Skin Call Girls Dubai
Dark Dubai Call Girls O525547819 Skin Call Girls Dubai
 
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Gosainganj Lucknow best sexual service
 
VIP Call Girls Service Jamshedpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Jamshedpur Aishwarya 8250192130 Independent Escort Ser...VIP Call Girls Service Jamshedpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Jamshedpur Aishwarya 8250192130 Independent Escort Ser...
 
Call Girls In Prashant Vihar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCe
Call Girls In Prashant Vihar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCeCall Girls In Prashant Vihar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCe
Call Girls In Prashant Vihar꧁❤ 🔝 9953056974🔝❤꧂ Escort ServiCe
 
Booking open Available Pune Call Girls Ambegaon Khurd 6297143586 Call Hot In...
Booking open Available Pune Call Girls Ambegaon Khurd  6297143586 Call Hot In...Booking open Available Pune Call Girls Ambegaon Khurd  6297143586 Call Hot In...
Booking open Available Pune Call Girls Ambegaon Khurd 6297143586 Call Hot In...
 
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
 
VIP Kolkata Call Girl Lake Gardens 👉 8250192130 Available With Room
VIP Kolkata Call Girl Lake Gardens 👉 8250192130  Available With RoomVIP Kolkata Call Girl Lake Gardens 👉 8250192130  Available With Room
VIP Kolkata Call Girl Lake Gardens 👉 8250192130 Available With Room
 
Final Completion Certificate of Marketing Management Internship
Final Completion Certificate of Marketing Management InternshipFinal Completion Certificate of Marketing Management Internship
Final Completion Certificate of Marketing Management Internship
 
Vip Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
Vip  Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...Vip  Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
Vip Modals Call Girls (Delhi) Rohini 9711199171✔️ Full night Service for one...
 
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service BhiwandiVIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
VIP Call Girl Bhiwandi Aashi 8250192130 Independent Escort Service Bhiwandi
 
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Greater Noida 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 

Array 2 hina

  • 2. .BCA II SEM. SUBMITTED TO: CHETAN SIR SUBMITTED BY : HINA KHAN
  • 3. Prakash Khaire The Mandvi Education Society Institute of Computer Science A R R A Y S
  • 4. CONTENTS  Introduction  Need for on array  Types of array • 1D • 2D • MD  Difference between 1D & 2D Array  Array Applications  Advantages & disadvantages
  • 5. What is an Array ?
  • 6. • It is derived data type. • The nature of array is static (fix). • Array is a collection of similar or homogeneous data type. • Array is also known subscript variable or index variable.
  • 7. • The lower bond of an array is zero 0. • The upper bond of an array is n-1. for ex.-int a[9] is an array that stores 9 integers • Array index start with zero(0). • Array end with n-1. 0 1 2 3 4 5 6 7 8 100 102 104 106 108 110 112 114 116 index elements Memory address
  • 9. NEED FOR AN ARRAY • To store large number of variables of same type under a single variable. • E.g. To store Marks of 50 students. Record of sales of 100 salesman.
  • 11.
  • 12. A list of items can be given one variable name using only one subscript and such a variable is called a one- dimensional Array. •Syntax data_type ArrayName[size]; data_type : is a valid data type like int, float,char Arrayname : is a valid identifier size : maximum number of elements that can be stored in array
  • 13. 1. Declaration of on Array To declare an array to syntax is- Data_ type variablename [size]; o The type of data which you want to store like – int , float , char. o Means the name of an Array. o The number of Array type variable. Ex.- int a [3]; • Type of array variable is “integer”. • Its variable name is a. • 3 is the size of the array.
  • 14. 2. Initialization • An elements of an array must be initialized, otherwise they may contain “garbage” value. • An array can be initialized at either of the following stages o At compile time o At run time • At the time of declaration and initialization at the same time. • For ex.- int a[5]={1,2,3,4,5} An array can be explicitly in initialization at run time. • To initialize multiple array variable for loop is used. for ex.- for (i=0;i<5;i++) { scanf (“%d”,&a[i]); }
  • 15. 3.Assessing • To print the element of an array is known as assessing. • To assessing the element of an array for loop is used frequently. for ex.- for (i=0; i<5 ;i++) { printf (“%d”,a[i]); } OUTPUT: 0 1 2 3 4
  • 16. Examples:- 1) Enter a one-d array #include<stdio.h> int main() { int a[10],i; printf(“enter the array=“); for(i=0;i<10;i++) { scanf(“%d”,&a[i]); } printf(“the entered array is=“); for(i=0;i<10;i++) { printf(“%d”,a[i]); } return(0); }
  • 18. • C allows us to define such tables of items by using two-dimensional arrays. •The two dimensional array are declared as follows- type array_name[row_size][column_size]; For ex.- int a [3][2]; Data type Array name Row=3 Column=2
  • 19. 1. Declaration 2D ARRAY • To declare an array to syntax is. • The syntax of 2D array is datatype arrayname[row] [column]; 2.Initializing 2D ARRAY • Like 1D array ,2D array initialized. • Tow for loop is used . ex.- for (i=0 ;i<3; i++) { for (j=0;j<3;j++) { scanf(“%d”,&a[i][j]); } }
  • 20. 3.Assessing 2D ARRAY • For loop is used. Ex.- for (i=0; i<3; i++) { for(j=0; j<3;j++) { printf(“t%d”,a[i][j]); } print(“n”); } • To print the element of an array is known as assessing.
  • 21. /* addition of two matrix/* #include<stdio.h> int main() { int i,j; int a[3][3],b[3][3],c[3][3]; for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf(“enter the matrix a=”); scanf(“%d”,&a[i][j]); } } for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf(“enter the matrix b=”); scanf(“%d”,&b[i][j]); }
  • 22. for(i=0;i<3;i++) { for(j=0;j<3;j++) { c[i][j]=a[i][j]+b[i][j]; } } Printf(“/n addition of two matrix=“); { for(i=0;i<3;i++) { for(J=0;j<3;j++) { printf(“%d”,c[i][j]); } printf(“/n”); } } return(0); }
  • 23. output: A= B= C= 9 8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8 9 10 10 10 10 10 10 10 10 10
  • 24. /*subtraction of two matrix/* #include<stdio.h> int main() { int i,j; int a[3][3],b[3][3],c[3][3]; for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf(“enter the matrix a=”); scanf(“%d”,&a[i][j]); } } for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf(“enter the matrix b=”); scanf(“%d”,&b[i][j]); }
  • 25. for(i=0;i<3;i++) { for(j=0;j<3;j++) { c[i][j]=a[i][j]-b[i][j]; } } Printf(“/n substract of two matrix=”); { for(i=0;i<3;i++) { for(J=0;j<3;j++) { printf(“%d”,c[i][j]); } printf(“/n”); } } return(0); }
  • 26. output: A= B= C= 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 1 1 1
  • 27. /*multiplication of two matrix/* #include<stdio.h> int main() { int i,j,k; int a[3][3],b[3][3],c[3][3]; for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf(“enter the matrix a=”); scanf(“%d”,&a[i][j]); } } for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf(“enter the matrix b=”); scanf(“%d”,&b[i][j]); }
  • 28. for(i=0;i<3;i++) { for(j=0;j<3;j++) { c[i][j]=0; for(k=0;k<3;k++) { c[i][j]=c[i][j]+a[i][k]*b[k][j]; } } } printf(“n enter the matix a is =”); for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf(“t%d”,c[i][j]); } printf(“n”); }
  • 29. printf(“n enter the matrix b is =”); for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf(“t%d”,b[i][j]); } printf(“n”); } printf(“n the multiplication is =”); for(i=0;i<3;i++) { for(j=0;j<3;j++) { printf(“t%d”,c[i][j]); } printf(“n”); } return(0); }
  • 30. output: A= B= AB= 1 2 3 4 5 6 7 8 9 9 8 7 6 5 4 3 2 1 46 28 10 118 73 28 190 118 46
  • 31. Not in courseNot in course
  • 32. • C allows arrays of three or more dimensions. The exact limit is determined by the compiler •Syntax- Datatype aray_name[s1][s2][s3]………….[Sm]; • For ex- int MyArray[2][3][4];
  • 33.
  • 34. DIFFERENCE 1D 1. 1D Array contains single row and multiple columns. 2. 1D Array is a simple collection of elements. 3. Ex:- 2d 1. 2D Array contains multiple row and multiple columns. 2. 2D Array is a collection of 1D Array . 3. Ex:- 1 2 3 4 1 2 3 4 A 1 2 3 B 4 5 6 C 7 8 9
  • 36. Array Applications • Array can be used for sorting elements. • Array can perform matrix operation. • Array can be used to sum all the elements. • Array can be stores elements of same data type.
  • 37. • Given a list of test scores, determine the maximum and minimum scores. • Read in a list of student names and rearrange them in alphabetical order (sorting). • Given the height measurements of students in a class, output the names of those students who are taller than average.
  • 39. Advantages  It is used to represent multiple data of same type by assigning only single name.  It can be used to implement other data structures like – linked lists , stacks ,queue etc….  2D array are used to represent matrices.
  • 40. Disadvantages  We must know array is static structure It means that array is fixed size. The memory which is allocated to array can not be increased or reduced.  Since array is of fixed size , if we allocate more memory than requirement then the memory space will be wasted . And if we allocate less memory than requirement than it will create problem.  The elements of array are stored in consecutive memory location. So insertions and deletion are very difficult and time consuming.
  • 41.  Programming in ANSI (E balagurusamy)  Thank you Chetan Sir for giving me this topic I would like to thank my friends who helped meEkta, Sakina, Kunal