Question #326249

Odd-Even-inator

by CodeChum Admin

My friends are geeking out with this new device I invented. It checks if a number is even or odd! 🤯 


Do you want to try it out?


Instructions:

  1. In the code editor, you are provided with a function that checks whether a number is even or odd.
  2. Your task is to ask the user for the number of integer, n, they want to input and then the actual n number values. For each of the number, check whether it is even or odd using the function provided for you.
  3. Make sure to print the correct, required message.

Input


1. Integer n

2. N integer values


Expert's answer

#include <stdio.h>

int main()
{
    int i, n;
    printf("Enter n: ");
    scanf("%d", &n);
    getchar();
    int arr[n];
    printf("Enter %d integer values:\n");
    for (i=0; i<n; i++)
        scanf("%d", &arr[i]);
    printf("\nRezult:\n");
    for (i=0; i <n; i++)
    {
        if (arr[i] % 2 == 0)
            printf("%d - Even\n", arr[i]);
        else
            printf("%d - Odd\n", arr[i]);;
    }
    getchar();
    return 0;
}
LATEST TUTORIALS
APPROVED BY CLIENTS