Program : Write a program in C to Sort N Integer Using Bubble Sort
Created By : JABIR PATHAN
#include<stdio.h>
#include<conio.h>
void main()
{
int arr[100],i,j,temp,n;
clrscr();
printf("Enter the How many Elements you want to enter in array==>");
scanf("%d",&n);
for(i=0;i<=n-1;i++)
{
printf("\nEnter elements for arr[%d]=",i);
scanf("%d",&arr[i]);
}
printf("\n\nAccepted Array Elements Are==>\n ");
for(i=0;i<=n-1;i++)
{
printf("\n arr[%d]=%d",i,arr[i]);
}
for(i=0;i<=n-1;i++)
{
for(j=0;j<=n-1;j++)
{
if(arr[j]>arr[i])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
printf("\n\n\nThe content of an array in an ascending order are==>\n");
for(i=0;i<=n-1;i++)
{
printf("\narr[%d]=%d",i,arr[i]);
}
getch();
}
Created By : JABIR PATHAN
#include<stdio.h>
#include<conio.h>
void main()
{
int arr[100],i,j,temp,n;
clrscr();
printf("Enter the How many Elements you want to enter in array==>");
scanf("%d",&n);
for(i=0;i<=n-1;i++)
{
printf("\nEnter elements for arr[%d]=",i);
scanf("%d",&arr[i]);
}
printf("\n\nAccepted Array Elements Are==>\n ");
for(i=0;i<=n-1;i++)
{
printf("\n arr[%d]=%d",i,arr[i]);
}
for(i=0;i<=n-1;i++)
{
for(j=0;j<=n-1;j++)
{
if(arr[j]>arr[i])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
printf("\n\n\nThe content of an array in an ascending order are==>\n");
for(i=0;i<=n-1;i++)
{
printf("\narr[%d]=%d",i,arr[i]);
}
getch();
}
No comments:
Post a Comment