39 lines
		
	
	
	
		
			772 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			39 lines
		
	
	
	
		
			772 B
		
	
	
	
		
			C
		
	
	
	
	
	
#include <stdio.h>
 | 
						|
 | 
						|
int main()
 | 
						|
{
 | 
						|
    int n,i,j,temp;
 | 
						|
    int flag=0;
 | 
						|
 | 
						|
    printf("Enter the number of elements you want in the array: ");
 | 
						|
    scanf("%d",&n);
 | 
						|
 | 
						|
    int arr[n];
 | 
						|
 | 
						|
    printf("Enter the numbers you want in the array:\n");
 | 
						|
    for(i=0;i<n;i++){
 | 
						|
        scanf("%d",&arr[i]);
 | 
						|
    }
 | 
						|
 | 
						|
    printf("The numbers in the array are:\n");
 | 
						|
    for(i=0;i<n;i++){
 | 
						|
        printf("%d\n",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("The numbers in the sorted array are:\n");
 | 
						|
    for(i=0;i<n;i++){
 | 
						|
        printf("%d\n",arr[i]);
 | 
						|
    }
 | 
						|
}
 | 
						|
 |