Finding Max and Min of an Array -C
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
//freopen("input.txt","r",stdin);
int ara[101],n;
scanf("%d",&n);
int i,j;
for(i=0;i<n;i++)
{
scanf("%d",&ara[i]);
}
int max=ara[0],min=ara[0];
for(i=0;i<n;i++)
{
if(max<ara[i]) max=ara[i];
if(min>ara[i]) min=ara[i];
}
printf("%d %d\n",max,min);
return 0;
}
No comments