Skip to content

Commit 4345e3f

Browse files
committed
Create problem16.c
1 parent deffd50 commit 4345e3f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

problem16.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//SOlved by Supreetha M, CSE
2+
3+
#include<stdio.h>
4+
int main()
5+
{
6+
int a[50],temp,comp=0,i,j;
7+
printf("\n Enter the array elements");
8+
for(i=0;i<50;i++)
9+
scanf("%d",&a[i]);
10+
for(i=0;i<50;i++)
11+
for(j=i+1;j<50;j++)
12+
{
13+
if(a[i]<a[j])
14+
{
15+
temp=a[i];
16+
a[i]=a[j];
17+
a[j]=temp;
18+
comp=comp+1;
19+
}
20+
}
21+
printf("\n The second largest element in the given array is : " , a[1]);
22+
printf("\n The number of comparisons required are : " , comp);
23+
return 0;
24+
}

0 commit comments

Comments
 (0)