...

/

Solution Review: Check if the Given Character is an Alphabet

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!

Press + to interact
#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

Line No. 7: Sets the value of a character to a

Line No. 10 ...