I want to calculate second largest number from inputs. So I have written this code. But this code is prints 38 every time I run it no matter what input is. Please help me finding solution to this question. Thanks in advance.
#include<stdio.h>
int main()
{
    int a , b , c , d , max , max2;
    scanf("%d %d %d %d" , &a , &b , &c , &d);
    if (a>b && a>c && a>d)
        max = a;
    else if (b>a && b>c && b>d)
        max = b;
    else if (c>a && c>b && c>d)
        max = c;
    else
        max = d;
    if (max == a)
        if(b>c && b>d)
            b = max2;
        else if(c>c && c>b)
            c = max2;
        else
            d = max2;
    else if(b == max)
        if(a>c && a>d)
            a = max2;
        else if(c>a && c>d)
            c = max2;
        else
            d = max2;
    else if(c == max)
        if(a>d && a>b)
            a = max2;
        else if(b>a && b>d)
            b = max2;
        else
            d = max2;
    else if(d == max)
        if(a>c && a>b)
            a = max2;
        else if(b>a && b>c)
            b = max2;
        else
            c = max2;
    printf("%d" , max2);
}
 
     
     
    