Decreasing array

  • File name: Decreasing array
  • Size: 529 b
yes /


The following code returns 1 and prints out "The vector is ordered decreasingly" if the values of the array keyed in are decreasing order, for example, 35, 34, 33, 20, 15, 12, 10, 9, 5, 4.

In case you are not decreasing order the function returns 0 and displays "The vector is not ordained."

The values are stored in an array / vector of 10 fields with which we will work to save the entered numbers and to verify that it is decreasing.


#include <stdio.h>
#define DIM 10

int ordenado(double v[],int n){

    int aux=1;int i;

        else aux=0;
    return aux;

int main(){
    double x[DIM];int d=10;int aux;int i;

    printf("Escribe las componentes del vector de 10 elementos\n");

    if(aux==1)printf("El vector esta ordenado decrecientemente");
    else printf("El vector no esta ordenado");

    return 0;


More exercices in

No ratings yet - be the first to rate this.

Add a comment