SlideShare a Scribd company logo
1 of 11
Download to read offline
Lectures on Programming with Arrays
for
Open Educational Resource
On
Programming Concepts (EC208)
by
Dr. Piyush Charan
Assistant Professor
Department of Electronics and Communication Engg.
Integral University, Lucknow
Introduction to Arrays
11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 2
Simple program on Arrays to accept โ€˜nโ€™
numbers and display the same
11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 3
11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 4
11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 5
11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 6
11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 7
Sorting of Array- Bubble Sort
11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 8
#include<stdio.h>
#include<conio.h>
void main()
{
int a[50], n, i, j, temp;
clrscr();
printf("Enter the size of array=");
scanf("%d", &n);
printf("Enter the elements in the array: ");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
//Sorting Logic
printf("The Sorted Array in Ascending order is ");
for(i=0;i<=(n-2);i++)
{
for(j=0;j<=(n-2)-i;j++)
{
if (a[j]>a[j+1])
11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 9
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
//Printing Sorted Array Logic
for(i=0;i<n;i++)
{
printf("%d ",a[i]);
}
getch();
}
11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 10
Sum of Two Arrays
11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 11

More Related Content

Similar to Unit 4 Arrays

Profile of Dr. Brojo Kishore Mishra
Profile of Dr. Brojo Kishore MishraProfile of Dr. Brojo Kishore Mishra
Profile of Dr. Brojo Kishore Mishra
Dr. Brojo Kishore Mishra
ย 
Dr. Parkavi.A , Resume working-2020-v4
Dr. Parkavi.A , Resume working-2020-v4Dr. Parkavi.A , Resume working-2020-v4
Dr. Parkavi.A , Resume working-2020-v4
Parkavi A
ย 
CV_Salim_August-2016
CV_Salim_August-2016CV_Salim_August-2016
CV_Salim_August-2016
SALIM ISTYAQ
ย 
Presentation for wattle wednesday
Presentation for wattle wednesdayPresentation for wattle wednesday
Presentation for wattle wednesday
Lauren Kane
ย 
MATLAB training program Brochure modified.docx
MATLAB training program Brochure modified.docxMATLAB training program Brochure modified.docx
MATLAB training program Brochure modified.docx
Priyanka Reddy
ย 
CURRICULUM VITAE-10
CURRICULUM VITAE-10CURRICULUM VITAE-10
CURRICULUM VITAE-10
Mahaboo Qureshi
ย 

Similar to Unit 4 Arrays (20)

Unit 2 Lecture notes on Huffman coding
Unit 2 Lecture notes on Huffman codingUnit 2 Lecture notes on Huffman coding
Unit 2 Lecture notes on Huffman coding
ย 
Cv
CvCv
Cv
ย 
Research paper collection by vitul chauhan.pdf
Research paper collection by vitul chauhan.pdfResearch paper collection by vitul chauhan.pdf
Research paper collection by vitul chauhan.pdf
ย 
Profile of Dr. Brojo Kishore Mishra
Profile of Dr. Brojo Kishore MishraProfile of Dr. Brojo Kishore Mishra
Profile of Dr. Brojo Kishore Mishra
ย 
VTU FINAL YEAR PROJECT REPORT Front pages
VTU FINAL YEAR PROJECT REPORT Front pagesVTU FINAL YEAR PROJECT REPORT Front pages
VTU FINAL YEAR PROJECT REPORT Front pages
ย 
Dr. Parkavi.A , Resume working-2020-v4
Dr. Parkavi.A , Resume working-2020-v4Dr. Parkavi.A , Resume working-2020-v4
Dr. Parkavi.A , Resume working-2020-v4
ย 
Vivek cv
Vivek cvVivek cv
Vivek cv
ย 
Bayesian networks in AI
Bayesian networks in AIBayesian networks in AI
Bayesian networks in AI
ย 
CV_Salim_August-2016
CV_Salim_August-2016CV_Salim_August-2016
CV_Salim_August-2016
ย 
Industrial Automation 2009 Edition
Industrial Automation 2009 EditionIndustrial Automation 2009 Edition
Industrial Automation 2009 Edition
ย 
Short Profile
Short ProfileShort Profile
Short Profile
ย 
Mumbai University Syllabus Electronics and telecommunication branch revies 2016
Mumbai University Syllabus Electronics and telecommunication branch  revies 2016Mumbai University Syllabus Electronics and telecommunication branch  revies 2016
Mumbai University Syllabus Electronics and telecommunication branch revies 2016
ย 
Presentation for wattle wednesday
Presentation for wattle wednesdayPresentation for wattle wednesday
Presentation for wattle wednesday
ย 
Essence Drives Software Engineering Education
Essence Drives Software Engineering EducationEssence Drives Software Engineering Education
Essence Drives Software Engineering Education
ย 
Quantum biology
Quantum biologyQuantum biology
Quantum biology
ย 
MATLAB training program Brochure modified.docx
MATLAB training program Brochure modified.docxMATLAB training program Brochure modified.docx
MATLAB training program Brochure modified.docx
ย 
CV
CVCV
CV
ย 
Unit 3 Dictionary based Compression Techniques
Unit 3 Dictionary based Compression TechniquesUnit 3 Dictionary based Compression Techniques
Unit 3 Dictionary based Compression Techniques
ย 
M.Venkateshkumar Profile
M.Venkateshkumar  Profile M.Venkateshkumar  Profile
M.Venkateshkumar Profile
ย 
CURRICULUM VITAE-10
CURRICULUM VITAE-10CURRICULUM VITAE-10
CURRICULUM VITAE-10
ย 

More from Dr Piyush Charan

More from Dr Piyush Charan (20)

Unit 1- Intro to Wireless Standards.pdf
Unit 1- Intro to Wireless Standards.pdfUnit 1- Intro to Wireless Standards.pdf
Unit 1- Intro to Wireless Standards.pdf
ย 
Unit 1 Solar Collectors
Unit 1 Solar CollectorsUnit 1 Solar Collectors
Unit 1 Solar Collectors
ย 
Unit 5 Quantization
Unit 5 QuantizationUnit 5 Quantization
Unit 5 Quantization
ย 
Unit 2: Programming Language Tools
Unit 2:  Programming Language ToolsUnit 2:  Programming Language Tools
Unit 2: Programming Language Tools
ย 
Unit 3 introduction to programming
Unit 3 introduction to programmingUnit 3 introduction to programming
Unit 3 introduction to programming
ย 
Forensics and wireless body area networks
Forensics and wireless body area networksForensics and wireless body area networks
Forensics and wireless body area networks
ย 
Final PhD Defense Presentation
Final PhD Defense PresentationFinal PhD Defense Presentation
Final PhD Defense Presentation
ย 
Unit 3 Arithmetic Coding
Unit 3 Arithmetic CodingUnit 3 Arithmetic Coding
Unit 3 Arithmetic Coding
ย 
Unit 1 Introduction to Data Compression
Unit 1 Introduction to Data CompressionUnit 1 Introduction to Data Compression
Unit 1 Introduction to Data Compression
ย 
Unit 1 Introduction to Non-Conventional Energy Resources
Unit 1 Introduction to Non-Conventional Energy ResourcesUnit 1 Introduction to Non-Conventional Energy Resources
Unit 1 Introduction to Non-Conventional Energy Resources
ย 
Unit 5-Operational Amplifiers and Electronic Measurement Devices
Unit 5-Operational Amplifiers and Electronic Measurement DevicesUnit 5-Operational Amplifiers and Electronic Measurement Devices
Unit 5-Operational Amplifiers and Electronic Measurement Devices
ย 
Unit 1 Introduction to Data Compression
Unit 1 Introduction to Data CompressionUnit 1 Introduction to Data Compression
Unit 1 Introduction to Data Compression
ย 
Unit 4 Switching Theory and Logic Gates
Unit 4 Switching Theory and Logic GatesUnit 4 Switching Theory and Logic Gates
Unit 4 Switching Theory and Logic Gates
ย 
Unit 1 Numerical Problems on PN Junction Diode
Unit 1 Numerical Problems on PN Junction DiodeUnit 1 Numerical Problems on PN Junction Diode
Unit 1 Numerical Problems on PN Junction Diode
ย 
Unit 5 Global Issues- Early life of Prophet Muhammad
Unit 5 Global Issues- Early life of Prophet MuhammadUnit 5 Global Issues- Early life of Prophet Muhammad
Unit 5 Global Issues- Early life of Prophet Muhammad
ย 
Unit 4 Engineering Ethics
Unit 4 Engineering EthicsUnit 4 Engineering Ethics
Unit 4 Engineering Ethics
ย 
Unit 3 Professional Responsibility
Unit 3 Professional ResponsibilityUnit 3 Professional Responsibility
Unit 3 Professional Responsibility
ย 
Unit 5 oscillators and voltage regulators
Unit 5 oscillators and voltage regulatorsUnit 5 oscillators and voltage regulators
Unit 5 oscillators and voltage regulators
ย 
Unit 4 feedback amplifiers
Unit 4 feedback amplifiersUnit 4 feedback amplifiers
Unit 4 feedback amplifiers
ย 
Unit 1 Mechanism of Conduction in Semiconductors
Unit 1 Mechanism of Conduction in SemiconductorsUnit 1 Mechanism of Conduction in Semiconductors
Unit 1 Mechanism of Conduction in Semiconductors
ย 

Recently uploaded

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
ย 
Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort ServiceCall Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
ย 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
KreezheaRecto
ย 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
ย 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
ย 
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)

Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
ย 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
ย 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
ย 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdf
ย 
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 ...
ย 
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
ย 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
ย 
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
ย 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
ย 
Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort ServiceCall Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
Call Girls in Ramesh Nagar Delhi ๐Ÿ’ฏ Call Us ๐Ÿ”9953056974 ๐Ÿ” Escort Service
ย 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
ย 
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
ย 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
ย 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ย 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
ย 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
ย 
Top Rated Pune Call Girls Budhwar Peth โŸŸ 6297143586 โŸŸ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth โŸŸ 6297143586 โŸŸ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth โŸŸ 6297143586 โŸŸ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth โŸŸ 6297143586 โŸŸ Call Me For Genuine Se...
ย 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
ย 
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
ย 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
ย 

Unit 4 Arrays

  • 1. Lectures on Programming with Arrays for Open Educational Resource On Programming Concepts (EC208) by Dr. Piyush Charan Assistant Professor Department of Electronics and Communication Engg. Integral University, Lucknow
  • 2. Introduction to Arrays 11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 2
  • 3. Simple program on Arrays to accept โ€˜nโ€™ numbers and display the same 11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 3
  • 4. 11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 4
  • 5. 11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 5
  • 6. 11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 6
  • 7. 11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 7
  • 8. Sorting of Array- Bubble Sort 11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 8 #include<stdio.h> #include<conio.h> void main() { int a[50], n, i, j, temp; clrscr(); printf("Enter the size of array="); scanf("%d", &n); printf("Enter the elements in the array: "); for(i=0;i<n;i++) { scanf("%d",&a[i]); } //Sorting Logic printf("The Sorted Array in Ascending order is "); for(i=0;i<=(n-2);i++) { for(j=0;j<=(n-2)-i;j++) { if (a[j]>a[j+1])
  • 9. 11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 9 { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } } //Printing Sorted Array Logic for(i=0;i<n;i++) { printf("%d ",a[i]); } getch(); }
  • 10. 11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 10 Sum of Two Arrays
  • 11. 11/2/2020 Dr. Piyush Charan, Dept. of ECE, Integral University, Lucknow 11