- 1Top 100 C Programs with Examples and Explanations
- 2C Hello World Program
- 3C Program to Print Your Own Name
- 4C Program to Print an Integer Entered by the User
- 5C Program to Add Two Numbers
- 6C Program to Check Whether a Number is Prime or Not
- 7C Program to Multiply Two Floating‑Point Numbers
- 8C Program to Print the ASCII Value of a Character
- 9C Program to Swap Two Numbers
- 10C Program to Calculate Fahrenheit to Celsius
- 11C Program to Find the Size of int, float, double and char
- 12C Program - Add Two Complex Numbers
- 13C Program - Print Prime Numbers From 1 to N
- 14C Program - Find Simple Interest
- 15C Program - Find Compound Interest
- 16C Program - Area And Perimeter Of Rectangle
- 17C Program - Check Whether a Number is Positive, Negative, or Zero
- 18C Program - Check Whether Number is Even or Odd
- 19C Program - Check Whether a Character is Vowel or Consonant
- 20C Program - Find Largest Number Among Three Numbers
- 21C Program - Calculate Sum of Natural Numbers
- 22C Program - Print Alphabets From A to Z Using Loop
- 23C Program - Check Leap Year
- 24C Program - Find Factorial of a Number
- 25C Program - Make a Simple Calculator
- 26C Program - Generate Multiplication Table
- 27C Program - Print Fibonacci Series
- 28C Program - Find LCM of Two Numbers
- 29C Program - Check Armstrong Number
- 30C Program - Display Armstrong Numbers Between 1 to 1000
- 31C Program - Display Armstrong Number Between Two Intervals
- 32C Program - Reverse a Number
- 33C Program - Check Whether a Number is a Palindrome or Not
- 34C Program - Display Prime Numbers Between Intervals
- 35C Program - Check whether the input number is a Neon Number
- 36C Program - Find All Factors of a Natural Number
- 37C Program - Print Simple Pyramid Pattern
- 38C Program - Print Given Triangle
- 39C Program - Print 180° Rotation of Simple Pyramid
- 40C Program - Print Inverted Pyramid
- 41C Program - Print Number Pattern
- 42C Program to Print Character Pattern
- 43C Program to Print Hollow Star Pyramid
- 44C Program to Print Pascal's Pattern Triangle Pyramid
- 45C Program to Print Floyd's Pattern Triangle Pyramid
- 46C Program to Check Prime Number By Creating a Function
- 47C Program to Display Prime Numbers Between Two Intervals Using Functions
- 48C Program to Find All Roots of a Quadratic Equation
- 49C Program to Check Whether a Number can be Express as Sum of Two Prime Numbers
- 50C Program to Find the Sum of Natural Numbers using Recursion
- 51C Program to Calculate the Factorial of a Number Using Recursion
- 52C Program to Find G.C.D Using Recursion
- 53C Program to Calculate Power Using Recursion
- 54C Program to Print a 2D Array
- 55C Program to Find the Largest Element in an Array
- 56C Program to Find the Maximum and Minimum in an Array
- 57C Program to Search an Element in an Array (Binary search)
- 58C Program to Calculate the Average of All the Elements Present in an Array
- 59C Program to Sort an Array using Bubble Sort
- 60C Program to Sort an Array using Merge Sort
- 61C Program to Sort an Array Using Selection Sort
- 62C Program to Sort an Array Using Insertion Sort
- 63C Program to Sort the Elements of an Array in Descending Order
- 64C Program to Sort the Elements of an Array in Ascending Order
- 65C Program to Remove Duplicate Elements From a Sorted Array
- 66C Program to Merge Two Arrays
- 67C Program to Find Common Array Elements
- 68C Program to Copy All the Elements of One Array to Another Array
- 69C Program to Array Rotation
- 70C Program to Sort the 2D Array Across Rows
- 71C Program to Check Whether Two Matrices Are Equal or Not
- 72C Program to Find the Transpose
- 73C Program to Find the Determinant of a Matrix
- 74C Program to Find the Normal and Trace
- 75C Program to Add Two Matrices
- 76C Program to Multiply Two Matrices
- 77C Program to Print Boundary Elements of a Matrix
- 78C Program to Rotate Matrix Elements
- 79C Program to Compute the Sum of Diagonals of a Matrix
- 80C Program to Interchange Elements of First and Last in a Matrix Across Rows
- 81C Program to Add or Concatenate Two Strings
- 82C Program to Add 2 Binary Strings
- 83C Program to Get a Non-Repeating Character From the Given String
- 84C Program to Check if the string is palindrome or not
- 85C Program to Reverse an Array or String
- 86C Program to Reverse a String Using Recursion
- 87C Program to Find the Length of a String
- 88C Program to Sort a String
- 89C Program to Check For Pangram String
- 90C Program to Print the First Letter of Each Word
- 91C Program to Remove Leading Zeros
- 92C Program to Compute Quotient and Remainder
- 93C Program to Demonstrate the Working of Keyword long
- 94C Program to Check Whether a Character is an Alphabet or not
- 95C Program to Count Number of Digits in an Integer
- 96C Program to Calculate the Power of a Number
- 97C Program to Reverse a Sentence Using Recursion
- 98C Program to Calculate Standard Deviation
- 99C Program to Multiply two Matrices by Passing Matrix to a Function
- 100C Program to Swap Numbers in Cyclic Order Using Call by Reference
- 101C Program to Remove all Characters in a String Except Alphabets
- 102C Character Pattern Program
- 103C Hollow Star Pyramid Pattern
- 104C Floyd's Triangle Program
- 105C Pascal's Triangle Program
- 106C Prime Number Check using Function
- 107C Prime Numbers in Range using Functions
C Program to Find the Maximum and Minimum in an Array - Source Code, Output & Execution Flow
C Program to Find the Maximum and Minimum in an Array
This C program finds both maximum and minimum values in an array.
#include <stdio.h>
int main() {
int a[] = {8, 3, 15, 1, 9};
int i, max = a[0], min = a[0];
for (i = 1; i < 5; i++) {
if (a[i] > max) max = a[i];
if (a[i] < min) min = a[i];
}
printf("Maximum = %d, Minimum = %d
", max, min);
return 0;
}
Maximum = 15, Minimum = 1
In this program, the input is read first when required, the core logic is applied step by step, and the final result is displayed using printf(). Follow the execution flow beside the code to understand how each statement contributes to the output.
⬅ Previous TopicC Program to Find the Largest Element in an Array
Next Topic ⮕C Program to Search an Element in an Array (Binary search)
Next Topic ⮕C Program to Search an Element in an Array (Binary search)