Programming Blog

This blog is about technical and programming questions and there solutions. I also cover programs that were asked in various interviews, it will help you to crack the coding round of various interviews

Wednesday, 3 January 2018

C program to find the second largest

#include <stdio.h>
#include<conio.h>
int main()
{
    int a,b,c,lar,seclar;
    clrscr();
    scanf("%d%d%d",&a,&b,&c);
    if(a>b)
    {
        if(a>c)
            lar=a;
        else
            seclar=a;
    }
    if(b>c)
    {
        if(b>a)
            lar=a;
        else
            seclar=b;
    }
    if(c>a)
    {
        if(c>b)
            lar=c;
        else
            seclar=c;
    }
    printf("second largest number :%d",seclar);
getch();

}

No comments:

Post a Comment