C Program to find the Largest and Smallest element in Array1 min read

In this tutorial, we will learn how to write a C Program to Find the Largest and Smallest Number in an Array. Before continuing, you should have knowledge of the following topics in C programming.


Program to find Largest and Smallest Element in an Array in C

The programs take user inputs for the size of an array and the values of the elements Then the variables to store the largest and smallest (large, small) element is initialized to the 0th position of an array.

Then the program is run through the for loop and inside it, two if statements are present that are executed if the largest or the smallest element is encountered. The literation loops for the size of an array.

Lastly, the small and large value is displayed along with their respective position (starts from 1).

Output:

Enter the size for an array: 5
Enter 5 elements of an array:
66
2
77
9
15
The largest element is 77 at 3 position.
The smallest element is: 2 at 2 position.


MORE

Find the output ab, cd, ef, g for the input a,b,c,d,e,f,g in Javascript and Python

In this tutorial, we will write a program to find a pairs of elements from an array such that for the input [a,b,c,d,e,f,g] we will …

String Pattern Programs in C

In this tutorial, we will write various C pattern programs for String. Before that, you may go through the following topics in C. for loop …

Java Program to Find pair of Integers in Array whose sum is given Number

In this tutorial, we will write a program to find a pair of elements from an array whose sum equals a given number in java …

Program to Print Diamond Alphabet Patterns in C

In this tutorial, we will learn to write a C program to print Diamond patterns using alphabets/characters. However, in this tutorial, we will create a …

Half Diamond Pattern in C using Alphabets

In this tutorial, we will learn and code the half diamond alphabet patterns in C programming language. However, in this tutorial, we will create a …

Half Pyramid of Alphabets in C

In this tutorial, we will learn and code alphabet patterns in C programming language specifically the Half pyramid of alphabets in C programming. However, in …