Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Program written by Mst. Sima Khatun */
- //bubble sort
- #include<stdio.h>
- int main()
- {
- int n,i,j,temp;
- printf("Enter how many number you want to assign to the array \n");
- scanf("%d",&n);
- int num[n];
- printf("enter %d number to the array \n",n);
- for(i=0;i<n;i++)
- {
- scanf("%d",&num[i]);
- }
- for(i=0;i<n;i++)
- {
- for(j=0;j<n-i;j++)
- {
- if(num[j]>num[j+1])
- {
- temp = num[j];
- num[j] = num[j+1];
- num[j+1] = temp;
- }
- // printf("%d\n",num[j]);
- }
- // printf("\n\n");
- }
- //printf("\n\n\n*********************************\n\n");
- for(i=0;i<n;i++)
- {
- printf("%d ",num[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement