Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
511 B
1
Indexable
Never
#include <stdio.h>
#include <stdlib.h>

int main(voi)
{

    /// TA Solution
    char num_string;
    int odd = 0, even = 0;
    int i = 0;

    printf("Enter a string of numbers ending with '#': ");
    while(scanf("%c", &num_string) && num_string != '#'){
        if(num_string % 2 == 0){
            even++;
        }
        else{
            odd++;
        }
        i++;
    }
    printf("There are %d odd numbers and %d even numbers in the string.\n", odd, even);

    return 0;
}