Ad Code

Finding the Smallest Number in an Array Using C Programming Language.

 Smallest Element in Array

Welcome to this tutorial where you will learn how to find the smallest number in an array using the C programming language.

Arrays are a collection of similar data types, and they are widely used in programming. In many programming tasks, finding the smallest number in an array is an essential requirement, and being able to perform this operation efficiently is a valuable skill.


In this tutorial, we will provide you with a comprehensive guide to finding the smallest number in an array using the C programming language. We will cover different methods to perform this operation, including using loops and functions.

You will learn how to write a C program to find the smallest number in an array, and we will also provide you with clear explanations and easy-to-understand examples.

This tutorial is similar to the previous tutorial on finding the largest number in an array, but with a different focus on finding the smallest number. By understanding both methods, you will have a thorough understanding of how to perform array operations using C programming language.

Example: 

We have an array a[10]={3,44,32,11,4,2,66,54,60,54}

So,  2  is the smallest number in this array.

Source code:

 #include <stdio.h>
 #include <conio.h>
 int main()
 {
    int a[10],i,small;
    printf("Enter the number of array: ");
    for(i=0;i<10;i++){
        scanf("%d",&a[i]);
    }
    printf("The Smallest number of array is: ");
    small=a[0];
    for(i=0;i<10;i++){
        if(small<a[i]){
        small=small;
        }
        else{
        small=a[i];
        }
    }
    printf("%d",samll);
    return 0;
 }

Output:

Enter the number of array: 
5
34
55
443
22
33
555
44
3
51

The Smallest number of array is: 3

Post a Comment

0 Comments

Ad Code