Program in C to find the maximum value in array

Write a program in C to find the maximum value in array

#include<stdio.h>
#include<conio.h>

void main()
{
            int a[5],max,i;
            clrscr();
            printf(“enter elements for the array\n”);
            for(i=0;i<5;i++)
                        scanf(“%d”,&a[i]);
            max=a[0];
            for(i=1;i<5;i++)
            {
                        if(max<a[i])
                                    max=a[i];
            }
            printf(“the maximum value is%d”,max);
            getch();
}


Post a Comment