C program to find total number of largest element of an array

 C program to find total number of largest element of an array



/*************************************************

 C program to find total number of largest element of an array

 * ************************************************/


#include<stdio.h>

#include<conio.h>

void main()

{

    int arr[100];

    int n,i,count=0;

    //clrscr();

    printf("How many array elements you want to store in an array\n");

    scanf("%d",&n);

    printf("Enter array elements\n");

    for(i=0;i<n;i++)

    {

        scanf("%d",&arr[i]);

    }

    printf("The array elements are\n");

    for(i=0;i<n;i++)

    {

        printf("%d\t",arr[i]);

        if(arr[0]<arr[i])

        {

            arr[0]=arr[i];

            count++;

        }

    }

    printf("\n");

    printf("Total largest elements in an array %d\n",count);

    printf("The largest array element is %d",arr[0]);

}

How many array elements you want to store in an array

5

Enter array elements

12 12 13 34 34

The array elements are

12 12 13 34 34

Total largest elements in an array 2

The largest array element is 34


टिप्पणी पोस्ट करा

0 टिप्पण्या