In this example, You will learn how to find largest of three characters using nested if statement in C++.
List is :a b c => c
List is :A b C => b
#include<iostream>
using namespace std;
int main() {
char a, b, c;
cout << "Enter three characters:";
cin >> a >> b >> c;
if (a > b) {
if (a > c) {
cout << "Largest is:" << a;
} else {
cout << "Largest is:" << c;
}
} else {
if (b > c) {
cout << "Largest is:" << b;
} else {
cout << "Largest is:" << c;
}
}
return 0;
}
Enter three characters:a b c
Largest is:c