Write a program to find second largest in an array.Take array values from the user

deepak maurya
0

 #include<stdio.h>

int main()

{

    int i,b,a[100],j,size;

    printf("inter the size\n");

    scanf("%d",&size);

    printf("inter the %d element\n",size);

    for ( i = 0; i < size; i++)

    {

        scanf("%d",&a[i]);

    }


    for ( i = 0; i <size; i++)

    {

       for(j=i+1;j<size;j++)

       {

          if(a[i]>a[j])

          {

          b=a[i];

          a[i]=a[j];

          a[j]=b;

          }

       }

    }

       i=size-2;

        printf(" second largest=%d ",a[i]);

}

Post a Comment

0Comments

Post a Comment (0)