How to present only odd and even values with three variables in C?

2

My variables are:

    int codigo; --> Sendo esta variável para o switch
    int numero1,numero2,numero3;

The user will enter three variables:

         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);

After this, I need to make the program check on each variable, what are its even and odd numbers.

For example, the user in the first variable named numero1 type número 20 , with this, the program will have to go through to número 20 and show which numbers were even and odd.

After the user types in the variable numero2 , the número 19 , and again the previous check will be done.

Finally, the user types in the variable numero3 , the número 30 and again the same check.

I'm using a switch because the user will have other options as well. But how can I do this then? Using a for along with a do-while until you can get all the numbers and check which ones are odd and even?

    
asked by anonymous 28.03.2017 / 23:29

1 answer

2

I do not know much about C, and I do not know if I understood the question correctly (I can not comment yet so I could not ask, sorry)

I made this code to show the numbers stop, I would normally use only 1 variable for this, but you said that I needed 3 so I decided to do a function to show the pairs of it.

If you want the program to list and separate the odd-numbered pairs, let me know if I change

#include<stdio.h>

int main (void){
    int numero1;
    int numero2;
    int numero3;
    int count;

    void Par(int valor){
        for(count=1 ; count <= valor ; count++){
            if (count % 2 == 0){
                printf("%d \n", count);
            }
        }
    }

    printf("Digite o primeiro numero inteiro: ");
    scanf("%d", &numero1);
    Par(numero1);
    printf("Digite o segundo numero inteiro: ");
    scanf("%d",&numero2);
    Par(numero2);
    printf("Digite o terceiro numero inteiro: ");
    scanf ("%d",&numero3);
    Par(numero3);

}
    
29.03.2017 / 00:07