pastebin

Paste Search Dynamic
Recent pastes
Largest Smallest element
  1. #include <stdio.h>
  2. int main()
  3. {    int arr[100], n, i, small, large;
  4. printf("Enter the number of elements you want to insert : ");
  5.     scanf("%d", &n);
  6.     for (i = 0; i < n; i++)
  7.     {
  8.         printf("Enter element %d : ", i + 1);
  9.         scanf("%d", &arr[i]);
  10.     }
  11.     small = arr[0];
  12.     large = arr[0];
  13.     for (i = 1; i < n; i++)
  14.     {
  15.         if (arr[i] < small)
  16.         {
  17.             small = arr[i];
  18.         }
  19.                if (arr[i] > large)
  20.         {
  21.             large = arr[i];
  22.         }
  23.     }
  24.     printf("nLargest element is : %d", large);
  25.     printf("nSmallest element is : %d", small);
  26.     return 0;
  27. }
  28.  
Parsed in 0.009 seconds