A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

WAP in c to find Two largest values in an 2D array on using for loop

Program:


#include<stdio.h>
#include<conio.h>
int main()
{
int a[5],i,j,temp=0;
printf("Enter 5 values");
for(i=0;i<=4;i++)
{
   scanf("%d",&a[i]);
}
printf("Two largest values are ");
for(i=0;i<=4;i++)
{
   for(j=i;j<=4;j++)
   {
       if(a[i]<a[j])
       {
           temp=a[i];
           a[i]=a[j];
           a[j]=temp;
       }
   }
}
printf("%d and %d",a[0],a[1]);
getch();
}

OUTPUT:

LEARN TUTORIALS

.

.