# 7.3 ASCII Code

## 7.3 ASCII Code

1. \[3] Print the Character Variable as a Character and ASCII Code Value.
2. \[4] Print all the Digits with their ASCII Code Value separated by a space, and each digit in a separate line.
3. \[5] Print all the Uppercase Letters with their ASCII Code Values separated by a space, and each letter in a separate line.
4. \[6] Print all the Lowercase Letters with their ASCII Code Values separated by a space, and each letter in a separate line.
5. \[7] Print all the ASCII Characters with their ASCII Code Values.
6. \[8] Input a Character and Print that character and its ASCII Code.

## সমাধান

### \[3] Print the Character Variable as a Character and ASCII Code Value.

{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    char ch = 'A';
    
    printf("Character: %c\n", ch);
    printf("ASCII Code: %d\n", ch);
    
    return 0;
}
```
{% endcode %}

### \[4] Print all the Digits with their ASCII Code Value separated by a space, and each digit in a separate line.

{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    char ch;
    
    printf("Char => ASCII\n");
    for(ch = '0'; ch <= '9'; ch++) {
        printf("%c => %d\n", ch, ch);
    }
    
    return 0;
}
```
{% endcode %}

### \[5] Print all the Uppercase Letters with their ASCII Code Values separated by a space, and each letter in a separate line.

{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    char ch;
    
    printf("Char => ASCII\n");
    for(ch = 'A'; ch <= 'Z'; ch++) {
        printf("%c => %d\n", ch, ch);
    }
    
    return 0;
}
```
{% endcode %}

### \[6] Print all the Lowercase Letters with their ASCII Code Values separated by a space, and each letter in a separate line.

{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    char ch;
    
    printf("Char => ASCII\n");
    for(ch = 'a'; ch <= 'z'; ch++) {
        printf("%c => %d\n", ch, ch);
    }
    
    return 0;
}
```
{% endcode %}

### \[7] Print all the ASCII Characters with their ASCII Code Values.

{% tabs %}
{% tab title="char" %}
{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    char ch;
    
    printf("Char => ASCII\n");
    for(ch = 0; ch < 127; ch++) {
        printf("%c => %d\n", ch, ch);
    }
    
    return 0;
}
```
{% endcode %}
{% endtab %}

{% tab title="unsigned char" %}
{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    unsigned char ch;
    
    printf("Char => ASCII\n");
    for(ch = 0; ch < 255; ch++) {
        printf("%c => %d\n", ch, ch);
    }
    
    return 0;
}
```
{% endcode %}
{% endtab %}
{% endtabs %}

### \[8] Input a Character and Print its ASCII Code.

{% code lineNumbers="true" %}
```c
#include<stdio.h>
int main(){
    char ch;
    
    scanf(" %c", &ch);
    printf("Character: %c ASCII Code: %d\n", ch, ch);
    
    return 0;
}
```
{% endcode %}
