#include <stdio.h>
#include <stdint.h>
#include <ctype.h>
void classify_string(const char *str)
{
int i=0;
char n_flag=0;
char a_flag=0;
while(str[i])
{
if(isdigit(str[i]))
n_flag=1;
else if(isalpha(str[i]))
a_flag=1;
else
{
printf("MIXED");
return ;
}
i++;
}
if(n_flag && !a_flag) //actually a_flag=0 remains when we donot find any alphabet and n_flag=1 means we found numeric. When both are satisfied it tells that it is purely numeric.
printf("NUMERIC");
else if(a_flag && !n_flag) //same logic as above.
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