Key Features

Experienced Teachers
Smart Classes
Regular Test
Study Material

Well qualified teachers with industrial experience.

To visualise or understand topics very easly.

We are organizing online and offline regular test.

We are providing prescribed study material.

Friday, October 30, 2020

Question : Write a C Program to find minimum element in array.

Question :  Write a C Program to find minimum element in array.

/*
Write a C Program to find minimum element in array.
*/

#include <stdio.h>
int main()
{
            int array[100], minimum, size, c, location = 1;
            printf("Enter number of elements in array\n");
            scanf("%d", &size);
            printf("Enter %d integers\n", size);
for (c = 0; c < size; c++)
            scanf("%d", &array[c]);
            minimum = array[0];
            for (c = 1; c < size; c++)
                        {
                                    if (array[c] < minimum)
                                                {
                                                 minimum = array[c];
                                                location = c+1;
                                                }
                         }
  
printf("Minimum element is present at location %d and its value is %d.\n", location, minimum);
    return 0;
}
OUTPUT :
Enter number of elements in array
5
Enter 5 integers
2
5
4
1
6
Minimum element is present at location 4 and its value is 1.

Thank you very much for reading carefully, if you have any other questions, you can share it with us through comments, if this information was important to you, please let us know through comments.

Please do comment and share.
Thank You.

No comments:

Post a Comment