# 7.5 Character Conversion

## 7.5 Character Conversion

1. \[19] to\_lower - Convert an Uppercase Letter to a Lowercase Letter.
2. \[20] to\_upper - Convert a Lowercase Letter to a Uppercase Letter.
3. \[21] reverse\_case - Reverse Case (If the character is in uppercase convert it to lowercase and vice versa)

## সমাধান

### \[19] to\_lower - Convert an Uppercase Letter to a Lowercase Letter.

{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main() {
    char ch, lower_case;
    
    scanf(" %c", &ch);
    if(ch >= 'A' && ch <= 'Z'){
        lower_case = ch - 'A' + 'a';
        printf("%c\n", lower_case);
    }
    else{
        printf("%c\n", ch);
    }

    return 0;
}
```
{% endcode %}

### \[20] to\_upper - Convert a Lowercase Letter to a Uppercase Letter.

{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main() {
    char ch, upper_case;
    
    scanf(" %c", &ch);
    if(ch >= 'a' && ch <= 'z'){
        upper_case = ch - 'a' + 'A';
        printf("%c\n", upper_case);
    }
    else{
        printf("%c\n", ch);
    }

    return 0;
}
```
{% endcode %}

### \[21] reverse\_case - Reverse Case (If the character is in uppercase convert it to lowercase and vice versa)

{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main() {
    char ch, reverse_case;
    
    scanf(" %c", &ch);
    if(ch >= 'A' && ch <= 'Z'){
        reverse_case = ch - 'A' + 'a';
    }
    else if(ch >= 'a' && ch <= 'z'){
        reverse_case = ch - 'a' + 'A';
    }
    else{
        reverse_case = ch;
    }
    printf("%c\n", reverse_case);

    return 0;
}
```
{% endcode %}
