Q:

C programming code using pointers

0

C programming code using pointers

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include 

int main()
{
    int array[100], *minimum, size, c, location = 1;
   
    printf("Enter the 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;
    *minimum = *array;
   
    for (c = 1; c < size; c++)
    {
        if (*(array+c) < *minimum)
        {
           *minimum = *(array+c);
           location = c+1;
        }
    }
   
    printf("Minimum element found at location %d and it's value is %d.\n", location, *minimum);
    return 0;
}

output:

Enter number of elements in array

3

Enter 3 integers

1

2

3

Minimum element is present at location 1 and its value is 1.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now