Hey guys,
I'm a newbie in C and I've got to make an app:
Users enter 10 numbers;
I've got to compare them;
At the end tell the user if
a) Number are decreasing (ex: 10 9 8 7 6 5 4 3 2 1 0)
b) Number are creasing (ex: 1 2 3 4 5 6 7 8 9 10)
c) Number are equals (ex: 4 4 4 4 4 4 4 4 4 4)
d) Number are disorderly (ex: 9 8 2 7 4 9 2 3 0)
I've made this:
#include <stdlib.h>
#include <stdio.h>
int main ()
{
int Vecteur[10] = {0}, i, CompteurA = 0, CompteurB = 0;
printf("Entrez vos dix nombres: \n");
for(i = 0; i < 9; i++)
{
scanf("%d ", &Vecteur[i]);
}
for(i = 0; i < 9; i++)
{
if(Vecteur[i] > Vecteur[i+1])
{
CompteurA++;
}
if(Vecteur[i] < Vecteur[i+1])
{
CompteurB++;
}
}
printf("%d\n", CompteurA);
printf("%d", CompteurB);
if(CompteurA == 9)
{
printf("Decroissant");
}
else
{
if(CompteurB == 8)
{
printf("Croissant");
}
}
}
I haven't done yet the rest but I was wondering if we were oblige to use all these "if"...
Is there an other way but a newbies way?
Thanks.