Question: Can someone please provide me some examples? Thank you :)

```
#include <stdio.h>

int main()
{
    int tcount = 0, ccount = 0, dcount = 0;
    char ch;
    printf("Enter your characters (! to end): \n");

    /* What program code to write to get the result? */

    printf("digits: %d\n", dcount);
    printf("letters: %d\n", ccount);
    return 0;
}

```

is it using for loop?

```
    for (tcount=0;tcount<10;tcount++)
    {
        scanf("%c",&ch);
        if(ch == '!')
            break;
    }

```

Test Result:

hello 5432 user#

digits: 4 letters: 9

Answer: 
I would recommend you to use `getchar()` instead of `scanf()` for reading single characters.

Or if you have to, you have to skip leading whitespaces

```
scanf(" %c",&ch);
       ^                 Note the space

```

---

Here is a simple example which could be helpful to you, using functions `isdigit()` and `isalpha()` from `ctype.h` library.

```
int c, numberCounter = 0, letterCounter = 0;
while ((c = getchar()) != '!')
{
    if (isalpha(c))
    {
        letterCounter++;
    }
    else if (isdigit(c))
    {
        numberCounter++;
    }
}

```

If you can't use additional libraries like `ctype.h`, take a look at the [ASCII](https://cs.wikipedia.org/wiki/ASCII) table, for example

```
if (c >= '0' && c <= '9')  // '0' == 48, '9' == 57
{
    // c is digit
}

```
Yes you need to use a loop for, or a while:

```
 for (tcount=0;tcount<10;tcount++)
{
    scanf("%c",&ch);
    if(ch == '!')
        break;
}

```

or the while code:

```
while(ch != '!'){
    scanf("%c",&ch);
    printf("There are nothing to see here");
}

```