#include <stdio.h>
#include <stdint.h>
#define NUM_ZERO ('0')
#define NUM_NINE ('9')
#define CHAR_A ('A')
#define CHAR_Z ('Z')
#define CHAR_a ('a')
#define CHAR_z ('z')
#define IS_NUMERIC(chr) ((chr) >= NUM_ZERO && (chr) <= NUM_NINE)
#define IS_ALPHA(chr) (((chr) >= CHAR_A && (chr) <= CHAR_Z) || ((chr) >= CHAR_a && (chr) <= CHAR_z))
void classify_string(const char *str) {
// Your logic here
int num_count=0;
int alpha_count=0;
while((*str)&&
((0 == num_count)||(0 == alpha_count))){
if(IS_NUMERIC(*str)){
num_count++;
}
else if(IS_ALPHA(*str)){
alpha_count++;
}
else{
num_count++;
alpha_count++;
}
str++;
}
if((0 != num_count)&&(0 == alpha_count)){
printf("NUMERIC");
}
else if((0 == num_count)&&(0 != alpha_count)){
printf("ALPHABETIC");
}
else{
printf("MIXED");
}
}
int main() {
char str[101];
fgets(str, sizeof(str), stdin);
// Remove newline
uint8_t i = 0;
while (str[i]) {
if (str[i] == '\n') {
str[i] = '\0';
break;
}
i++;
}
classify_string(str);
return 0;
}
Input
123456
Expected Output
NUMERIC