find max and min element from array using function


int maxmin(int num)
{
    int min , max ,i,a[100], x , y;

    int n=num;
    printf(" Enter the elements in  array : ");
    for(i=0 ; i<n ; i++)
    {
        scanf("%d",&a[i]);
    }
    max = a[0];
    min = a[0];

    for(i=1; i<n; i++)
    {
         if(min > a[i])
            min = a[i];

        if(max < a[i])
            max = a[i];
    }

     printf(" \n The maximum array is :%d",max);
    printf("\n The minimum array is : %d",min);
}


int main()
{
    int i , num, min, max,x, y;

    printf(" Enter the size of the array : ");
    scanf("%d",&num);



    x = maxmin(num);



    return 0 ;
}


OUTPUT :



For Other Programs Visit The WebSite:-   https://www.techapurba.com/

Follow Me On Social Media :-





For tech related videos visit my other website :- https://apurbatechinfo.blogspot.com/


Post a Comment

0 Comments