Advertisement
Fahim_789

Lab_Task-1-4

Aug 6th, 2019
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int i,n,large,small;
  5.     int a[100];
  6.     printf("Enter the size : ");
  7.     scanf("%d",&n);
  8.     printf("Enter the array elements :");
  9.     for(i=0;i<n;i++)
  10.     {
  11.         scanf("%d",&a[i]);
  12.     }
  13.     large=small=a[0];
  14.     for(i=1;i<n;i++)
  15.     {
  16.         if(a[i]>large)
  17.            large=a[i];
  18.         if(a[i]<small)
  19.            small=a[i];
  20.     }
  21.     printf("Largest=%d\n",large);
  22.     printf("Smallest=%d\n",small);
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement