C++ program to minimum and maximum element in given list array.

#include<iostream.h>

#include<conio.h>

#define n 10

void main(){

float list[n],min,max;

int i;

clrscr();

cout<<"enter an elements of array list"<<endl;

for(i=0;i<n;i++){

cout<<"enter "<<i+1<<" element=";

cin>>list[i];

}

min=max=list[0];

for(i=1;i<n;i++){

if(min>list[i]) min=list[i];

if(max<list[i]) max=list[i];

}

cout<<"Minimum element in list array is="<<min<<endl;

cout<<"Maximum element in list array is="<<max<<endl;

getch();

}


No comments:

Post a Comment