Code:
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main()
{
char str[80];
int countUpper = 0;
int countLower = 0;
int len;
int i;
printf("\nEnter a sentence:");
fgets(str, sizeof(str), stdin);
len = strlen(str);
for (i=0; i<len;i++){
if (isalpha(str[i])){
printf("\nstr[%d] is alpha", i);
if (islower(str[i])){
printf("\nstr[%d] is lowecase",i);
countLower ++;
}
else{
printf("\nstr[%d] is upper", i);
countUpper ++;
}
if (isdigit(str[i])){
printf("\nstr[%d] is Digit", i);
}
else
printf("\nstr [%d] is Not alpha nor digit", i);
}
}
return 0;
}
Still doesnt work .. Here is the output>
Enter a sentence:Hello World001!
str[0] is alpha
str[0] is upper
str [0] is Not alpha nor digit
str[1] is alpha
str[1] is lowecase
str [1] is Not alpha nor digit
str[2] is alpha
str[2] is lowecase
str [2] is Not alpha nor digit
str[3] is alpha
str[3] is lowecase
str [3] is Not alpha nor digit
str[4] is alpha
str[4] is lowecase
str [4] is Not alpha nor digit
str[6] is alpha
str[6] is upper
str [6] is Not alpha nor digit
str[7] is alpha
str[7] is lowecase
str [7] is Not alpha nor digit
str[8] is alpha
str[8] is lowecase
str [8] is Not alpha nor digit
str[9] is alpha
str[9] is lowecase
str [9] is Not alpha nor digit
str[10] is alpha
str[10] is lowecase
str [10] is Not alpha nor digitPress any key to continue . . .
Looks Funny.