2
I have three variables :
int numero1,numero2,numero3;
After you have declared them, I am asked the user to fill them in :
printf("Digite o primeiro numero inteiro: ");
scanf("%d", &numero1);
printf("Digite o segundo numero inteiro: ");
scanf("%d",&numero2);
printf("Digite o terceiro numero inteiro: ");
scanf ("%d",&numero3);
And based on this, I need to verify which of the numbers typed by the user are negative.
I have a method that checks whether the numbers typed are positive :
void Positivo(int valor) {
for(count = 1;count <= valor; count++) {
if(count > 0) {
printf("%d \n",count);
}
}
}
And I also have one that checks if the numbers typed are negative :
void Negativo(int valor) {
for(count = 0;count >= valor; count++) {
if(count < 0) {
printf("%d \n", count);
}
}
}
The problem is that when typing the numbers, they do not appear anything, because it seems that it is not recognized by the function scanf()
the negative numbers.
Screenshot of the program :
So how can I fix this ? Causing the user to enter the negative numbers, can read the variables correctly, and show only the negative numbers.
I believe that in the case, who posted the problem, does not want to use arrays to solve the problem, since according to what it shows in the problem, it intends to use integers.
– Falion
So, that’s exactly what @Falion said, I need to use whole numbers and not arrays. If possible, I would like to know how to check with integers.
– Mondial
@Edilson It was not I who denied, nor do I even have enough points to be able to deny. Thank you for your patience.
– Mondial
@Edilson The code worked, thank you very much.
– Mondial
@Sure, problem will be if you have to add more numbers.
– Edilson