Write a program which reads an array of 7 integers then represents them in an increasing order.


Difficulty level
This exercise is mostly suitable for students
#include <stdio.h>
#include <math.h>
int main()
{
    int A[7];
    int I, J, aux;      
    

    for (I=0 ; I<7 ; I++)
    {
            printf("Enter element %d : ", I+1);
            scanf("%d", &A[I]);
    }
 
    for (I=0 ; I<6 ; I++)
        for(J=I+1; J<7; J++)
            if(A[I]>A[J])
            {
                aux=A[I];
                A[I]=A[J];
                A[J]=aux;
            }

    for (I=0 ; I<7 ; I++)
            printf("%d ", A[I]);
    printf("\n");
    
    return 0;
} 

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Right rotate an array