In this program, You will learn how to find second largest digit of a number in C++.

`Number is : 1234 = 3`

## Example: How to find the second largest digit of a number in C++.

```
#include<iostream>
using namespace std;
int main() {
int n, num, rev=0;
int r, lar = 0, sl = 0;
cout << "Enter a number:";
cin>>n;
while (n > 0) {
r = n % 10;
if (lar < r) {
lar = r;
}
rev = rev * 10 + r;
n = n / 10;
}
n = rev;
while (n > 0) {
r = n % 10;
if (lar != r) {
if (sl < r) {
sl = r;
}
}
n = n / 10;
}
cout << "Second largest digit:" << sl;
return 0;
}
```

#### Output:

```
Enter a number:3241
Second largest digit:3
```