C Program to Find Maximum and Minimum from 10 Numbers

Introduction:

Finding the maximum and minimum number from a set of values is one of the most common beginner-level programming problems. This tutorial explains how to write a C program to find maximum and minimum from 10 numbers using loops and conditional checks.

This is an essential concept that helps build skills in loops, conditionals, arrays, and logic.


Problem Statement:

Write a C program that:

  • Takes 10 numbers as input from the user.
  • Identifies and displays the maximum and minimum values from the entered numbers.

C Program Code:

#include <stdio.h>

int main() {
int numbers[10], i;
int max, min;

// Input 10 numbers from user
printf("Enter 10 numbers:\n");
for (i = 0; i < 10; i++) {
scanf("%d", &numbers[i]);
}

// Initialize max and min with first number
max = min = numbers[0];

// Compare each number with current max and min
for (i = 1; i < 10; i++) {
if (numbers[i] > max) {
max = numbers[i];
}
if (numbers[i] < min) {
min = numbers[i];
}
}

// Display results
printf("Maximum number is: %d\n", max);
printf("Minimum number is: %d\n", min);

return 0;
}

Explanation of the Code:

  • An array of size 10 is used to store user input.
  • We initialize both max and min with the first number.
  • The program then loops through the rest of the array, updating max and min as it finds higher or lower values.
  • Finally, it prints the maximum and minimum values.

Why It Matters:

  • Teaches basic looping and array traversal
  • Enhances understanding of comparative logic
  • Common use case in real-world data analysis or search operations

Where This Logic Is Used:

  • Stock price analysis
  • Performance tracking systems
  • Exam result evaluation
  • Any form of range or threshold calculations

Conclusion:

This program demonstrates a fundamental use case in C programming — finding maximum and minimum values from a set of inputs. It’s simple, efficient, and a great way to practice loops, conditionals, and array handling.

Previous Article

C Program to Print Day of the Week for Numbers 1 to 7

Next Article

C Program to Check if Last Digit of a Number is Even or Odd

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *

Subscribe to our Newsletter

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨