I have three variables:
int numero1,numero2,numero3;
Once you have declared them, I am asked the user to populate them:
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 check which of the numbers entered by the user are negative.
I have a method that checks whether the numbers entered 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 verifies that the numbers entered 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 the negative numbers are not recognized by the function scanf()
.
Screenshot of the program:
So, how can I solve this? By having the user enter negative numbers, he can read the variables correctly, and show only the negative numbers.