mardi 10 novembre 2020

Use multiple variables in a loop [SOLVED]

I'm trying to check if five numbers are odd or even. I want to use a for-loop that iterates 5 times and uses a for loop that checks if the number is odd or even.

Code:

#include <stdio.h>

int main()
{
    int a ,b ,c ,d ,e;

    scanf("%d %d %d %d %d", &a, &b ,&c ,&d ,&e);

    int count = 5;

    for (int i = 0; i < count; i++)
    {
        
        if(num % 2 == 0) //num should be a then b then c etc.

        printf("even");

        else

        printf("odd");
    }

}   

I cant find any information about swapping/switching variables inside a loop/statment. If anyone has an answer or where to find the information i will be forever grateful!

Thanks in advance! //Noob programmer

Aucun commentaire:

Enregistrer un commentaire