C Program to Print Smallest and Largest Integers of an Array
In this program we will take an array as input from user and print the smallest and largest integers from that array.
- //C program to print smallest and largest integers of an array
-
- #include <stdio.h>
- #include <stdlib.h>
-
- void maxmin(int arr[], int n, int i)
- {
- int max=arr[0];
- int min=arr[0];
- for(i=0; i<n; i++)
- {
- if(arr[i]>max)
- {
- max=arr[i];
- }
- else if(arr[i]<min)
- {
- min=arr[i];
- }
- }
- printf("Largest elt is %d", max);
- printf("\nSmallest elt is %d", min);
- }
- int main()
- {
- int arr[10], i, n;
- printf("enter limit: ");
- scanf("%d", &n);
- printf("enter elts: ");
- for(i=0; i<n; i++)
- {
- scanf("%d", &arr[i]);
- }
- maxmin(arr, i, n);
- return 0;
- }
Output

Solution not working or have any suggestions? Please send an email to [email protected]
Download Android App