0
The code is ignoring the type variable int
and is receiving real values.
Also, when I enter a character it returns that is zero and not that it is not a valid number.
Identify whether it is positive, negative or zero works.
int main(void){
int Num;
printf("Digite um numero inteiro: ");
scanf("%f", &Num);
if(Num > 0){
printf("O numero e positivo");
}else if(Num < 0){
printf("O numero e negativo");
}else if(Num == 0){
printf("O numero e zero");
}else{
printf("Nao e um numero valido");
}
}
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).
– Maniero