Remaining Programs
Remaining Programs
Remaining Programs
35
Aim- WAP to sort an array using bubble sort
#include<stdio.h>
int main()
{
int arr[100],a,i,j,temp;
printf("Enter the range of array : ");
scanf("%d",&a);
printf("Enter the value of array : ");
for(int i=0;i<a;i++)
{
scanf("%d",&arr[i]);
}
for(i=0;i<a;i++)
{
for(j=i+1;j<a;j++)
{
if(arr[i]>arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
for(i=0; i<a; i++)
{
printf("%d\t",arr[i]);
}
return 0;
}
Output :
Program no. 36
Aim- WAP to sort an array using insertion sort
#include <stdio.h>
int main()
{
int a[100], range, i, j, temp;
printf("\nEnter the Range of the array : ");
scanf("%d", &range);
Output :