Untitled

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

int main(void)
{
    char num_string[100];
    int odd = 0, even = 0;

    printf("Enter a string of numbers ending with '#': ");
    scanf("%s", num_string);

    for(int i = 0; i < strlen(num_string); i++){
        if(num_string[i] == '#'){
            break;
        }
        else if(num_string[i] % 2 == 0){
            even++;
        }
        else{
            odd++;
        }
    }

    printf("There are %d odd numbers and %d even numbers in the string.\n", odd, even);
return 0;