Thursday , February 22 2018
Home / c-program / C Program – Find Largest and Smallest number in an Array

C Program – Find Largest and Smallest number in an Array

C Program to find the largest and smallest number in an array.

Largest and Smallest number in an Array :


#include<stdio.h>
int main(void)
{
    int i,int_arr[10]={6,4,5,0,2,-1,10,-5,15,9};
    int small,large;
    small=large=int_arr[0];
    for(i=1; i<10; i++)
    {
        if(int_arr[i] < small)
            small=int_arr[i];
        if(int_arr[i] > large)
            large=int_arr[i];
    }
    printf("Smallest Element : = %d\nLargest Element : = %d\n",small,large);
    return 0;
}

Smallest Element : = -5
Largest Element : = 15

Happy Learning 🙂

About chandrashekhar

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,

Recommended

C Program – Addition of two Matrices Example

C Program to Addition of two Matrices. Addition of two Matrices : Happy Learning 🙂

Leave a Reply

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