Have a Read!

Hi Everyone.
The idea for this page is to provide new c users simple c tutorials to learn how to develop the logic and more importantly correct way to write syntax.
ENJOY !!!

Sunday, February 6, 2011

C Program for Finding maximum entry in data

#include<stdio.h>
void array(int a[4][3]);
int locater(int b[4][3],int c);
int main()
{
    int marks,i;
    int record[4][3]={{12,25,67},{32,30,65},{15,34,70},{20,40,79}};
    printf("\n\n\n");
    array(record);
    for(i=0;i<3;i++)
        {
            marks=locater(record,i);
            if(i==0)
            {
            printf("\nThe Maximum lowest marks in all sections are %d\n",marks);
            }
            if(i==1)
            {
            printf("The Maximum Average in all sections are %d\n",marks);
            }
            if(i==2)
            {
            printf("The Maximum Highest marks in all sections are %d\n\n\n\n",marks);
            }
        }
    return 0;
}
void array(int a[4][3])
{
            int i,j;
            printf("Sections    Lowest Average Highest\n");
            printf("        marks  marks    marks\n"   );
                for(i=0;i<4;i++)
                    {   
                    printf("Section %d\t",i+1);
                    for(j=0;j<3;j++)
                        {
                            printf("%d\t",a[i][j]);
                        }   
                    printf("\n");
                    }
}
int locater(int a[4][3],int c)
{
            int x;
            for(x=0;x<4;x++)
            {
                if(a[x][c]>=a[1][c] && a[x][c]>=a[2][c] && a[x][c]>=a[3][c])
                               {   
                return a[x][c];       
                            }   
            }
}

No comments:

Post a Comment

Related Posts with Thumbnails