Bismillahir Rahmanir Rahim
Solution in C:
#include<stdio.h> void main() { int i, a[50],max,min,n; printf("How many times your are input (max: 50):\n"); scanf("%d",&n); printf("Enter your %d integer numbers:\n",n); for( i=0;i<n;i++) scanf("%d",&a[i]); max=min=a[0]; for( i=0;i<n;i++) { if(max<a[i]) max=a[i]; if(min>a[i] ) min=a[i]; } printf("Maximum= %d\n",max); printf("Minimum= %d",min); }
Solution in C++:
#include<iostream.h> void main() { int i, a[50],max,min,n; cout<<"How many times your are input (max: 50):"<<endl; cin>>n; cout<<"Enter your "<<n<<" integer numbers:"<<endl; for( i=0;i<n;i++) cin>>a[i]; max=min=a[0]; for( i=0;i<n;i++) { if(max<a[i]) max=a[i]; if(min>a[i] ) min=a[i]; } cout<<"Maximum="<<max<<endl<<"Minimum="<<min; }