Untitled
unknown
plain_text
4 years ago
554 B
4
Indexable
#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;
Editor is loading...