C Program to Find Largest Element in Array

Google Advertisements

Prev Tutorial Next Tutorial

Find Largest Element in Array Program in C

To write this code we receive input from user and store in array variable after that sort array elements and find Largest element.In this Code, we will find the Largest element of array by using linear search. Given an array of N elements, we have to find the Largest Element of Array.

Examples To C Program Find Largest Element from Array


Array : [9, 12, 11, 16, -14, 13, 0, -3]
Largest Element : 16

To understand below example, you have must knowledge of following C programming topics; String in C, for looping statements we need know For Loop in C and Array in C.

Algorithm to Find Largest Element of Array

  • First Take Number of elements as input from user. Let it be N.
  • Then ask user to enter N numbers and store it in an array(lets call it input).
  • Initialize one variables max with first element of input.
  • Using a loop, traverse input from index 0 to N -1 and compare each element with max.
  • If current element is less than max, then update max with current element.
  • After array traversal max will have the Largest element.

C Program to Find Largest Elements from Array


 void main()
    int array[100], count, i, largest;
    printf("Enter Number of Elements Want in Array\n");

    printf("Enter Any %d count Elemnts in Array \n", count);
    // Read array elements
    for(i = 0; i < count; i++)
    largest = array[0];
    // search num in inputArray from index 0 to elementCount-1 
    for(i = 0; i < count; i++)
	if(array[i] > largest)
	    largest = array[i];

    printf("Largest Element in Array is: %d",largest);


Enter Number of Elements in Array: 5
Enter Any 5 Elements in Array
Largest Element in Array is: 11
c program to find largest elements form array
Prev Tutorial Next Tutorial

Google Advertisements

We have more than 5 Groups which have 500000+ Members and some Pages have more than 100000+ members. For Advertisement contact on hitesh.xc@gmail.com or 9999595223

Buy This Ad Space @$50 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 8076671483

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Classpath variable is set for providing a path for predefined Java classes which is used in our application. All classes are available in lib/rt.jar so we set classpath upto lib/rt.jar. Difference between path and classpath in Java

Cloud computing is the on demand availability of computer system resources, especially data storage and computing power, without direct active management by the user. Cloud Computing Tutorial

College Projects Related to Java, AWT, C Projects for College, C++ Projects for College, Android Projects. Download Java C C++ Projects

Download Projects

Adsense Advertisements

Buy This ads Space 8076671483

Buy This Ad Space @$120 per Month, Ad Size 300X600 Contact on: hitesh.xc@gmail.com or 8076671483 Try this Keyword C++ Programs