3
Write a program to determine if a sequence of n numbers entered by the user is in ascending order or not. The user must provide how many numbers will be typed, ie the value of n.
I’m having trouble with this code, I couldn’t quite understand how to assemble it, I did one for what I understood, but I couldn’t develop it, if anyone has a tip to edit it, or show how to do it, comments there, thanks already...
#include <stdio.h>
int main()
{
int Vezes_Digitada, Digitada; /*Vezes que o usuario ia digitar, e quantas vezes ele digitou*/
float num; /*Numero que usuario ia digitar pra avaliação*/
printf("Quantos numeros voce ira digitar?");
scanf("%d", &Vezes_Digitada);
while(Digitada <= Vezes_Digitada) /*aqui eu queria que saisse do while quando as vezes
que você digitou chegasse ao numero de vezes que o usuario predefiniu, ex: digitou 15,
e ia aparecer pra vc digitar ate atingir o limite de 15 vezes digitadas*/
{
printf("%d Digite o numero:");
scanf("%f", &num);
}
if(num > num)
{
/*Eu sei que ta errado, mas a intenção era avaliar se os numeros
esta em ordem crescente ou não, mas nao sei como fazer isso*/
printf("Ordem crescente");
}
else
{
printf("Numeros digitados nao estao em ordem crescente");
}
return 0;
}
if I type 1 1 1 1 , from ascending order, is there any way to fix it? and thank you so much for your help
– WeslleyAF
@Weslleyaf Yes missed the
=
in theif
to stay>=
and not>
. It was just a distraction, but I’ll edit it right away– Isac
Thanks, but in which if?
– WeslleyAF
@Weslleyaf What’s inside the
while
/for
. I’ve already edited the answer– Isac
Ahh got it, thanks again
– WeslleyAF
@Weslleyaf No problem, we’re here to help.
– Isac
Do you know any way to fix this repeat part more? I’m having a hard time with this :/
– WeslleyAF
@Weslleyaf Fix ? What do you mean ?
– Isac
fix, improve, learn, develop... etc
– WeslleyAF
@Weslleyaf The best is the same as for everything, study the theory, be it by books, videos, classes, etc... And practice! Practice a lot, because without practice there is no way.
– Isac
Thank you, and good night :)
– WeslleyAF
because the increasing int=1 stood after the scanf? has some reason in particular, or could put that variable together in the other int?
– WeslleyAF
@Weslleyaf O
crescente
has already started with1
in its statement. The idea is that we are default to assume that the numbers are increasing and we update to0
if we see that some are no longer.– Isac