SlideShare a Scribd company logo
array
Some programs may need to handle same type of different number of data having same
characteristics. In such situation, it will be easier to handle such data in Array, where
same name is shared for all data with different subscripts. In an array, all the data items
must be of same type and same storage class. Eg. either int, floating point or characters
Each array element (individual array element) is denoted with a name followed by one or
more subscripts (where each subscript must be non negative integers within a pair of
square bracket).
The number of subscript depends on the dimensionality of the array. Eg. a[i] refers to an
element of one dimensional array. Whereas b[i][j] refers to an array element of two
dimensional array. In the same manner c[i][j][k] for three dimensional arry.
Defining an array
Array is also defined in the same manner as ordinary variables, but it should also include
the size of specification that shows the maximum size of elements in that array.
It is defined such as follows:
Storage_class data_type array[expression];
Prog 1:
To store integer nos in an array and print them (1 dim)
#include<stdio.h>
void main()
{
int i, x[10]={4,5,2,8,4,7,9,6,5};
printf("n The stored numbers in the array are:");
for(i=0;i<10;i++)
{
printf("n %d", x [ i ] );
}
}
Prog 2:
Modify prog 1 so that it allows to enter integer nos. those are to be stored in an array.
Prog 3:
Modify prog 2 so that it could find out sum, average & deviation of data with average
value.
Prog 4:
To sort a list of integer numbers in ascending order.
#include<stdio.h>
void main()
{
int i, x[10];
printf("n Enter numbers to be sorted :");
for(i=0;i<10;i++)
{
scanf("%d", &x [ i ] );
}
for(i=0;i<9;i++)
{
for(k=i+1;k<10;k++)
{
if(x [ i ] > x [ k ] )
{
temp = x [ i ];
x [ i ]= x [ k ];
x [ k ]= temp;
}
}
}
printf("n The sorted numbers are:");
for(i=0;i<10;i++)
{
printf("n %d", x [ i ] );
}
}
Processing an array
Lllllllll
Two dimensional array
Prog 5:
To store numbers in a two dimensional array and print them
Prog 6:
Modify prog 5 so that it allows to enter numbers.
Prog 7:
Write a program to find out sum of two matrices of size 2x2
Modify it for any size.
Prog 8:
To find out product of two matrices of size 3x2 & 2x1.
Passing array to a function
Prog 9:
To pass a list of numbers into an user defined function to change values of the array.
#include<stdio.h>
void modify (int x[ ])
{
int i;
for(i=0;i<3;i++)
{
x [ i ]=9;
}
}
void main()
{
int i, x[10];
printf("n Enter numbers to be stored in the array :");
for(i=0;i<3;i++)
{
scanf("%d", &x [ i ] );
}
modify(x);
printf("n The stored numbers in the array are:");
for(i=0;i<3;i++)
{
printf("n %d", x [ i ] );
}
}
Prog 10:
Modify prog 4 to sort a list of numbers passing to a function.

More Related Content

What's hot

Array in c programming
Array in c programmingArray in c programming
Array in c programming
Mazharul Islam
 
7.basic array
7.basic array7.basic array
7.basic array
Mir Riyanul Islam
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
Manojkumar C
 
Array in C
Array in CArray in C
Array in C
adityas29
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
Gagan Deep
 
Arrays in c language
Arrays in c languageArrays in c language
Arrays in c language
tanmaymodi4
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
sandhya yadav
 
Arrays
ArraysArrays
A Presentation About Array Manipulation(Insertion & Deletion in an array)
A Presentation About Array Manipulation(Insertion & Deletion in an array)A Presentation About Array Manipulation(Insertion & Deletion in an array)
A Presentation About Array Manipulation(Insertion & Deletion in an array)
Imdadul Himu
 
Data Structure Midterm Lesson Arrays
Data Structure Midterm Lesson ArraysData Structure Midterm Lesson Arrays
Data Structure Midterm Lesson Arrays
Maulen Bale
 
Arrays in c
Arrays in cArrays in c
Arrays in c
Jeeva Nanthini
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
topu93
 
Basic array in c programming
Basic array in c programmingBasic array in c programming
Basic array in c programming
Sajid Hasan
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
janani thirupathi
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
Surbhi Yadav
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
2569294Mohan
 
Array
ArrayArray
Array
Hajar
 
Arrays in C++
Arrays in C++Arrays in C++
Arrays in C++
Maliha Mehr
 
Lecture1 classes4
Lecture1 classes4Lecture1 classes4
Lecture1 classes4
Noor Faezah Mohd Yatim
 
Array C programming
Array C programmingArray C programming
Array C programming
Prionto Abdullah
 

What's hot (20)

Array in c programming
Array in c programmingArray in c programming
Array in c programming
 
7.basic array
7.basic array7.basic array
7.basic array
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
 
Array in C
Array in CArray in C
Array in C
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
 
Arrays in c language
Arrays in c languageArrays in c language
Arrays in c language
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 
Arrays
ArraysArrays
Arrays
 
A Presentation About Array Manipulation(Insertion & Deletion in an array)
A Presentation About Array Manipulation(Insertion & Deletion in an array)A Presentation About Array Manipulation(Insertion & Deletion in an array)
A Presentation About Array Manipulation(Insertion & Deletion in an array)
 
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
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
 
Basic array in c programming
Basic array in c programmingBasic array in c programming
Basic array in c programming
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
 
Array
ArrayArray
Array
 
Arrays in C++
Arrays in C++Arrays in C++
Arrays in C++
 
Lecture1 classes4
Lecture1 classes4Lecture1 classes4
Lecture1 classes4
 
Array C programming
Array C programmingArray C programming
Array C programming
 

Similar to Array

Arrays-Computer programming
Arrays-Computer programmingArrays-Computer programming
Arrays-Computer programming
nmahi96
 
Homework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdfHomework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdf
aroraopticals15
 
Arrays
ArraysArrays
Introduction to Arrays in C
Introduction to Arrays in CIntroduction to Arrays in C
Introduction to Arrays in C
Thesis Scientist Private Limited
 
Arrays and Strings
Arrays and Strings Arrays and Strings
Arrays and Strings
Dr.Subha Krishna
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functions
Swarup Boro
 
Lecture 1 mte 407
Lecture 1 mte 407Lecture 1 mte 407
Lecture 1 mte 407
rumanatasnim415
 
Lecture 1 mte 407
Lecture 1 mte 407Lecture 1 mte 407
Lecture 1 mte 407
rumanatasnim415
 
Array
ArrayArray
Array
hjasjhd
 
02 arrays
02 arrays02 arrays
02 arrays
Rajan Gautam
 
Arrays
ArraysArrays
Arrays
ArraysArrays
ARRAYS
ARRAYSARRAYS
ARRAYS
muniryaseen
 
CP Handout#7
CP Handout#7CP Handout#7
CP Handout#7
trupti1976
 
2 arrays
2   arrays2   arrays
2 arrays
trixiacruz
 
Unit ii data structure-converted
Unit  ii data structure-convertedUnit  ii data structure-converted
Unit ii data structure-converted
Shri Shankaracharya College, Bhilai,Junwani
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
Dushmanta Nath
 
arrays.docx
arrays.docxarrays.docx
Array and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdfArray and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdf
ajajkhan16
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
SajalFayyaz
 

Similar to Array (20)

Arrays-Computer programming
Arrays-Computer programmingArrays-Computer programming
Arrays-Computer programming
 
Homework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdfHomework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdf
 
Arrays
ArraysArrays
Arrays
 
Introduction to Arrays in C
Introduction to Arrays in CIntroduction to Arrays in C
Introduction to Arrays in C
 
Arrays and Strings
Arrays and Strings Arrays and Strings
Arrays and Strings
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functions
 
Lecture 1 mte 407
Lecture 1 mte 407Lecture 1 mte 407
Lecture 1 mte 407
 
Lecture 1 mte 407
Lecture 1 mte 407Lecture 1 mte 407
Lecture 1 mte 407
 
Array
ArrayArray
Array
 
02 arrays
02 arrays02 arrays
02 arrays
 
Arrays
ArraysArrays
Arrays
 
Arrays
ArraysArrays
Arrays
 
ARRAYS
ARRAYSARRAYS
ARRAYS
 
CP Handout#7
CP Handout#7CP Handout#7
CP Handout#7
 
2 arrays
2   arrays2   arrays
2 arrays
 
Unit ii data structure-converted
Unit  ii data structure-convertedUnit  ii data structure-converted
Unit ii data structure-converted
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
 
arrays.docx
arrays.docxarrays.docx
arrays.docx
 
Array and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdfArray and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdf
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 

More from Shankar Gangaju

Tutorial no. 8
Tutorial no. 8Tutorial no. 8
Tutorial no. 8
Shankar Gangaju
 
Tutorial no. 7
Tutorial no. 7Tutorial no. 7
Tutorial no. 7
Shankar Gangaju
 
Tutorial no. 6
Tutorial no. 6Tutorial no. 6
Tutorial no. 6
Shankar Gangaju
 
Tutorial no. 3(1)
Tutorial no. 3(1)Tutorial no. 3(1)
Tutorial no. 3(1)
Shankar Gangaju
 
Tutorial no. 5
Tutorial no. 5Tutorial no. 5
Tutorial no. 5
Shankar Gangaju
 
Tutorial no. 4
Tutorial no. 4Tutorial no. 4
Tutorial no. 4
Shankar Gangaju
 
Tutorial no. 2
Tutorial no. 2Tutorial no. 2
Tutorial no. 2
Shankar Gangaju
 
Tutorial no. 1.doc
Tutorial no. 1.docTutorial no. 1.doc
Tutorial no. 1.doc
Shankar Gangaju
 
What is a computer
What is a computerWhat is a computer
What is a computer
Shankar Gangaju
 
Pointer
PointerPointer
9.structure & union
9.structure & union9.structure & union
9.structure & union
Shankar Gangaju
 
5.program structure
5.program structure5.program structure
5.program structure
Shankar Gangaju
 
4. function
4. function4. function
4. function
Shankar Gangaju
 
3. control statement
3. control statement3. control statement
3. control statement
Shankar Gangaju
 
2. operator
2. operator2. operator
2. operator
Shankar Gangaju
 
1. introduction to computer
1. introduction to computer1. introduction to computer
1. introduction to computer
Shankar Gangaju
 
Ads lab
Ads labAds lab
Electromagnetic formula
Electromagnetic formulaElectromagnetic formula
Electromagnetic formula
Shankar Gangaju
 
Electromagnetic formula
Electromagnetic formulaElectromagnetic formula
Electromagnetic formula
Shankar Gangaju
 
5 g networks
5 g networks5 g networks
5 g networks
Shankar Gangaju
 

More from Shankar Gangaju (20)

Tutorial no. 8
Tutorial no. 8Tutorial no. 8
Tutorial no. 8
 
Tutorial no. 7
Tutorial no. 7Tutorial no. 7
Tutorial no. 7
 
Tutorial no. 6
Tutorial no. 6Tutorial no. 6
Tutorial no. 6
 
Tutorial no. 3(1)
Tutorial no. 3(1)Tutorial no. 3(1)
Tutorial no. 3(1)
 
Tutorial no. 5
Tutorial no. 5Tutorial no. 5
Tutorial no. 5
 
Tutorial no. 4
Tutorial no. 4Tutorial no. 4
Tutorial no. 4
 
Tutorial no. 2
Tutorial no. 2Tutorial no. 2
Tutorial no. 2
 
Tutorial no. 1.doc
Tutorial no. 1.docTutorial no. 1.doc
Tutorial no. 1.doc
 
What is a computer
What is a computerWhat is a computer
What is a computer
 
Pointer
PointerPointer
Pointer
 
9.structure & union
9.structure & union9.structure & union
9.structure & union
 
5.program structure
5.program structure5.program structure
5.program structure
 
4. function
4. function4. function
4. function
 
3. control statement
3. control statement3. control statement
3. control statement
 
2. operator
2. operator2. operator
2. operator
 
1. introduction to computer
1. introduction to computer1. introduction to computer
1. introduction to computer
 
Ads lab
Ads labAds lab
Ads lab
 
Electromagnetic formula
Electromagnetic formulaElectromagnetic formula
Electromagnetic formula
 
Electromagnetic formula
Electromagnetic formulaElectromagnetic formula
Electromagnetic formula
 
5 g networks
5 g networks5 g networks
5 g networks
 

Recently uploaded

Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 

Recently uploaded (20)

Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 

Array

  • 1. array Some programs may need to handle same type of different number of data having same characteristics. In such situation, it will be easier to handle such data in Array, where same name is shared for all data with different subscripts. In an array, all the data items must be of same type and same storage class. Eg. either int, floating point or characters Each array element (individual array element) is denoted with a name followed by one or more subscripts (where each subscript must be non negative integers within a pair of square bracket). The number of subscript depends on the dimensionality of the array. Eg. a[i] refers to an element of one dimensional array. Whereas b[i][j] refers to an array element of two dimensional array. In the same manner c[i][j][k] for three dimensional arry. Defining an array Array is also defined in the same manner as ordinary variables, but it should also include the size of specification that shows the maximum size of elements in that array. It is defined such as follows: Storage_class data_type array[expression]; Prog 1: To store integer nos in an array and print them (1 dim) #include<stdio.h> void main() { int i, x[10]={4,5,2,8,4,7,9,6,5}; printf("n The stored numbers in the array are:"); for(i=0;i<10;i++) { printf("n %d", x [ i ] ); } } Prog 2: Modify prog 1 so that it allows to enter integer nos. those are to be stored in an array. Prog 3: Modify prog 2 so that it could find out sum, average & deviation of data with average value.
  • 2. Prog 4: To sort a list of integer numbers in ascending order. #include<stdio.h> void main() { int i, x[10]; printf("n Enter numbers to be sorted :"); for(i=0;i<10;i++) { scanf("%d", &x [ i ] ); } for(i=0;i<9;i++) { for(k=i+1;k<10;k++) { if(x [ i ] > x [ k ] ) { temp = x [ i ]; x [ i ]= x [ k ]; x [ k ]= temp; } } } printf("n The sorted numbers are:"); for(i=0;i<10;i++) { printf("n %d", x [ i ] ); } } Processing an array Lllllllll Two dimensional array Prog 5:
  • 3. To store numbers in a two dimensional array and print them Prog 6: Modify prog 5 so that it allows to enter numbers. Prog 7: Write a program to find out sum of two matrices of size 2x2 Modify it for any size. Prog 8: To find out product of two matrices of size 3x2 & 2x1. Passing array to a function Prog 9: To pass a list of numbers into an user defined function to change values of the array. #include<stdio.h> void modify (int x[ ]) { int i; for(i=0;i<3;i++) { x [ i ]=9; } } void main() { int i, x[10]; printf("n Enter numbers to be stored in the array :"); for(i=0;i<3;i++) { scanf("%d", &x [ i ] ); } modify(x); printf("n The stored numbers in the array are:"); for(i=0;i<3;i++) { printf("n %d", x [ i ] );
  • 4. } } Prog 10: Modify prog 4 to sort a list of numbers passing to a function.