Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int n, i, j, k, temp;
- printf("Enter the number of elements of the array : ");
- scanf("%d", &n);
- int arr[n];
- printf("Enter the %d integers : ", n);
- for(i = 0; i < n; i++)
- scanf("%d", &arr[i]);
- for(i = 0; i < n - 1; i++)
- {
- for(j = 0; j < n - i - 1; j++)
- {
- if(arr[j] > arr[j + 1])
- {
- temp = arr[j];
- arr[j] = arr[j + 1];
- arr[j + 1] = temp;
- }
- }
- }
- printf("\nThe sorted array of integers : ");
- for(i = 0; i < n; i++)
- printf("%d ", arr[i]);
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement