AI Features

Solution Review: Check if the Given Character is an Alphabet

Let's see the detailed solution review of the challenge given in the previous lesson.

We'll cover the following...

Solution

Run the code below and see the output!

C++
#include <iostream>
using namespace std;
int main() {
// Initialize variable character
char character = 'a';
// if block
if (character >= 'A' && character <= 'Z') {
cout << "upper-case alphabet";
}
// else if block
else if (character >= 'a' && character <= 'z') {
cout << "lower-case alphabet";
}
// else block
else {
cout << "not an alphabet";
}
return 0;
}

Explanation

...