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
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