Mount a program that displays user-entered prints

0

Well, I'm having a hard time putting this together using for, I know how to make a program that displays even or odd numbers up to the number entered, but how do I display how many numbers the user reports in num ?

#include <stdio.h>
int main() {
    int op, num, x;

    printf("1.pares\n2.Impares\n");
    scanf("%d", &op);
    printf("Digite o numero de vezes que voce quer imprimir\n");
    scanf("%d", &num);

    if (op==1) { for (x=2; num>=x; x=x+2) {
    printf("%d\n", x); }
     }else if (op==2) {
     for (x=1; num>=x; x=x+2) {
        printf("%d\n", x);
     }
    }
}

The idea is for the user to choose between even or odd, and then choose how many numbers to display (eg, display 5 even numbers, display 3 odd numbers)

    
asked by anonymous 14.06.2018 / 19:10

0 answers