# 7.4 Character Test

## 7.4 Character Test

1. \[9] is\_upper - Check whether a Character is an Uppercase Letter or not.
2. \[10] is\_lower - Check whether a Character is a Lowercase Letter or not.
3. \[11] is\_alpha - Check whether a Character is an Alphabet or not.
4. \[12] is\_digit - Check whether a Character is a Digit or not.
5. \[13] is\_alphanum - Check whether a Character is an Alphanumeric Character or not.
6. \[14] is\_vowel - Check whether a Character is a Vowel or not.
   1. 1\. Use if-else.
   2. 2\. Use switch case.
7. \[15] is\_consonant - Check whether a Character is a Consonant or not.
8. \[16] is\_xdigit Check if the character is a hexadecimal digit.
9. \[17] is\_punct Check if the character is a punctuation character.
10. \[18] is\_equal - Test equality of two Characters.

## সমাধান

### \[9] is\_upper - Check whether a Character is an Uppercase Letter or not.

{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    char ch, lower_case;
    
    scanf(" %c", &ch);
    if(ch >= 'A' && ch <= 'Z'){
        printf("Uppercase Letter\n");
    }
    else{
        printf("Not Uppercase Letter\n");
    }

    return 0;
}
```

{% endcode %}

### \[10] is\_lower - Check whether a Character is a Lowercase Letter or not.

{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    char ch, lower_case;
    
    scanf(" %c", &ch);
    if(ch >= 'a' && ch <= 'z'){
        printf("Lowercase Letter\n");
    }
    else{
        printf("Not Lowercase Letter\n");
    }

    return 0;
}
```

{% endcode %}

### \[11] is\_alpha - Check whether a Character is an Alphabet or not.

{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    char ch, lower_case;
    
    scanf(" %c", &ch);
    if((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')){
        printf("Alphabet\n");
    }
    else{
        printf("Not Alphabet\n");
    }

    return 0;
}
```

{% endcode %}

### \[12] is\_digit - Check whether a Character is a Digit or not.

{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    char ch, lower_case;
    
    scanf(" %c", &ch);
    if(ch >= '0' && ch <= '9'){
        printf("Digit\n");
    }
    else{
        printf("Not Digit\n");
    }

    return 0;
}
```

{% endcode %}

### \[13] is\_alphanum - Check whether a Character is an Alphanumeric Character or not.

{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    char ch, lower_case;
    
    scanf(" %c", &ch);
    if((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9')){
        printf("Alphanumeric Character\n");
    }
    else{
        printf("Not Alphanumeric Character\n");
    }

    return 0;
}
```

{% endcode %}

### \[14] is\_vowel - Check whether a Character is a Vowel or not.

{% tabs %}
{% tab title="if else" %}
{% code overflow="wrap" lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    char ch, lower_case;
    
    scanf(" %c", &ch);
    if(ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U' || ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u'){
        printf("Vowel\n");
    }
    else{
        printf("Not Vowel\n");
    }

    return 0;
}
```

{% endcode %}
{% endtab %}

{% tab title="switch case" %}
{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    char ch, lower_case;
    
    scanf(" %c", &ch);    
    switch(ch){
        case 'A':
        case 'E':
        case 'I':
        case 'O':
        case 'U':
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
            printf("Vowel\n");
            break;
        default:
            printf("Not Vowel\n");
            break;
    }

    return 0;
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

### \[15] is\_consonant - Check whether a Character is a Consonant or not.

{% code overflow="wrap" lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    char ch, lower_case;
    
    scanf(" %c", &ch);
    if((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')){
        if(!(ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U' || ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')){
            printf("Consonant \n");
        }
        else{
            printf("Not Consonant\n");
        }
    }
    else{
        printf("Not Consonant\n");
    }

    return 0;
}
```

{% endcode %}

### \[16] is\_xdigit Check if the character is a hexadecimal digit. (function)

{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    char ch, lower_case;
    
    scanf(" %c", &ch);
    if((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F')){
        printf("Hexadecimal Digit\n");
    }
    else{
        printf("Not Hexadecimal Digit\n");
    }

    return 0;
}
```

{% endcode %}

### \[17] is\_punct Check if the character is a punctuation character. (function)

{% code overflow="wrap" lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    char ch, lower_case;
    
    scanf(" %c", &ch);
    if(ch == '!' || ch == '"' || ch == '#' || ch == '$' || ch == '%' || ch == '&' || ch == '\'' || ch == '('  || ch == ')' || ch == '*' || ch == '+' || ch == '-' || ch == '.' || ch == '/'|| ch == ':' || ch == ';' || ch == '<' || ch == '=' || ch == '>' || ch == '?' || ch == '@' || ch == '[' || ch == '\\' || ch == ']' || ch == '^' || ch == '_' || ch == '`' || ch == '{' || ch == '|' || ch == '}' || ch == '~'){
        printf("Punctuation Character\n");
    }
    else{
        printf("Not Punctuation Character\n");
    }

    return 0;
}
```

{% endcode %}

### \[18] is\_equal - Test equality of two Characters.

{% code lineNumbers="true" %}

```c
#include<stdio.h>
int main(){
    char ch1, ch2;
    
    scanf(" %c %c", &ch1, &ch2);
    if(ch1 == ch2){
        printf("Equal\n");
    }
    else{
        printf("Not Equal\n");
    }
    
    return 0;
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mun.gitbook.io/c/solution/8-character-and-string/7.4-character-test.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
