# Ascii

ASCII value = **Every character has a unique integer number assigned to it.**

**ASCII → American Standard Code for Information Interchange.**

Computer **doesn’t understand characters**, it understands **numbers**.  
So characters like `'A'`, `'B'`, `'a'`, `'1'`, `'*'` are stored internally as **numbers (0–127)**.

---

# ✅ **Simple Explanation**

Example:

| Character | ASCII Value |
| --- | --- |
| `'A'` | 65 |
| `'B'` | 66 |
| `'a'` | 97 |
| `'b'` | 98 |
| `'0'` | 48 |
| `'1'` | 49 |
| `' '` (space) | 32 |

So when you write:

```plaintext
char x = 'A';
cout << (int)x;
```

Output: **65**

Because `'A'` is stored as ASCII **65** inside memory.

---

# ✅ **Why ASCII matters in C++?**

### ✔ Characters are stored as integers

`char` type actually stores an **integer (0–255)**.

### ✔ You can convert easily

```plaintext
char ch = 'a';
int val = ch;   // 97
```

### ✔ Comparison works using ASCII

```plaintext
if ('a' < 'b')  // true because 97 < 98
```

### ✔ A–Z and a–z are in sequence

* 'A' → 65
    
* 'Z' → 90
    
* 'a' → 97
    
* 'z' → 122
    

So uppercase and lowercase alphabets are stored consecutively.

---

# ✔ Example Program

```plaintext
#include <iostream>
using namespace std;

int main() {
    char ch;
    cin >> ch;

    cout << "ASCII value of " << ch << " is " << int(ch);
}
```

Input:

```plaintext
A
```

Output:

```plaintext
ASCII value of A is 65
```
