#include<stdio.h>
#define MAX 50
int main( )
{
int arr[MAX], n, i, max, min;
printf("Enter the Number of elements");
scanf("%d",&n);
printf("Enter elements of array");
for(i=0; i<n; i++)
scanf("%d",&arr[i]);
max=min=arr[0];
for(i=1; i<n; i++)
{
if(arr[i]>max)
max=arr[i];
if(arr[i]<min)
min=arr[i];
}
printf("Largest and smallest element is %d %d", max, min);
return 0;
}
#define MAX 50
int main( )
{
int arr[MAX], n, i, max, min;
printf("Enter the Number of elements");
scanf("%d",&n);
printf("Enter elements of array");
for(i=0; i<n; i++)
scanf("%d",&arr[i]);
max=min=arr[0];
for(i=1; i<n; i++)
{
if(arr[i]>max)
max=arr[i];
if(arr[i]<min)
min=arr[i];
}
printf("Largest and smallest element is %d %d", max, min);
return 0;
}

0 Comments