Program to find maximum of elements of an array

Program(Without Using Function)

#include <stdio.h>
int main()
{
    printf("**************************************************************");
    printf("\n**************************************************************");
    printf("\n**       WAP to find maximum element from an array          **");
    printf("\n**             Created by Sheetal Garg                      **");
    printf("\n**               Assistant Professor                        **");
    printf("\n**               Phone No:9467863365                        **");
    printf("\n**************************************************************");
    printf("\n**************************************************************\n");
    int n, i, a[10], max;
    printf("Enter no. of elements in the array\n");
    scanf("%d", &n);
    printf("enter array elements");
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    max = a[0];
    for (i = 1; i < n; i++)
        if (a[i] > max)
            max = a[i];
    printf("Maximum of elements of array is %d", max);
    return 0;
}

Output

**************************************************************
**************************************************************
**       WAP to find maximum element from an array          **
**             Created by Sheetal Garg                      **
**               Assistant Professor                        **
**               Phone No:9467863365                        **
**************************************************************
**************************************************************
Enter no. of elements in the array
7
enter array elements
32
24
99
87
67
56
32
Maximum of elements of array is 99

Program(Using Function)

#include <stdio.h>
int findmax(int a[], int n)
{
    int max, i;
    max = a[0];
    for (i = 1; i < n; i++)
        if (a[i] > max)
            max = a[i];
    return max;
}
int main()
{
    printf("**************************************************************");
    printf("\n**************************************************************");
    printf("\n**       WAP to find maximum element from an array          **");
    printf("\n**             Created by Sheetal Garg                      **");
    printf("\n**               Assistant Professor                        **");
    printf("\n**               Phone No:9467863365                        **");
    printf("\n**************************************************************");
    printf("\n**************************************************************\n");
    int n, i, a[10], max;
    printf("Enter no. of elements in the array\n");
    scanf("%d", &n);
    printf("enter array elements");
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    max = findmax(a, n);
    printf("Maximum of elements of array is %d", max);
    return 0;
}

Output

**************************************************************
**************************************************************
**       WAP to find maximum element from an array          **
**             Created by Sheetal Garg                      **
**               Assistant Professor                        **
**               Phone No:9467863365                        **
**************************************************************
**************************************************************
Enter no. of elements in the array
7
enter array elements
32
24
99
87
67
56
32
Maximum of elements of array is 99
error: You can only copy the programs code and output from this website. You are not allowed to copy anything else.