Untitled
unknown
plain_text
7 months ago
541 B
3
Indexable
Never
#include <iostream> using namespace std; int main() { int n,i,max,min; cout<<"Enter number of elements of array"; cin>>n; int a[n]; cout<<"Enter elements of array"; for(i=0;i<n;i++) { cin>>a[i]; } max=a[0]; min= a[0]; for(i=0;i<n;i++) { if(a[i]>max) { max=a[i]; } } for(i=0;i<n;i++) { if(a[i]<min) { min=a[i]; } } cout<<max<<" is largest \n"; cout<<min<<" is minimum \n"; return 0; }
Leave a Comment