Saturday, October 22, 2011

heighest and lowest in a 2D array

#include <stdio.h>
#include <conio.h>
#include <math.h>
int main ()
{int a [31][10],i,j;
for(i=1;i<=3;++i)
for(j=1;j<=2;++j)
{scanf("%d",&a[i][j]);}
for(i=1;i<=3;++i)
for(j=1;j<=2;++j)
{if(a[1][1]>a[i][j])
{a[1][1]=a[i][j];}}
printf("lowest is %d",a[1][1])
;
for(i=1;i<=3;++i)
for(j=1;j<=2;++j)
{if(a[1][1]<a[i][j])
{a[1][1]=a[i][j];}}
printf("\n highst is %d",a[1][1]);




getch();
     return 0;
}

No comments:

Post a Comment