C++ program to find minimum and maximum element in array

without using function


#include<iostream>
using namespace std;
int main()
{
int a[100],n,i,min,max;
cout<<“Enter the size of arrayn”;
cin>>n;
cout<<“Enter the elements one by onen”;
for(i=0;i<n;i++)
cin>>a[i];
min=a[0];

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

if(a[i]<min)
{
min=a[i];
}
}
cout<<“min in the array is “<<min<<“n”;
max=a[0];
for(i=0;i<n;i++)
if(a[i]>max)
{
max=a[i];
}
cout<<“max in the array is “<<max;
}

OUTPUT:-
Enter the size of array
3
Enter the elements one by one
5
8
4
min in the array is 4
max in the array is 8

Leave a Comment

Your email address will not be published. Required fields are marked *

To Resolve this issue at just 5$ from ServerExpert

https://serverexpert.io/

For Hosting please visit Hostingwebsite.io

You have Successfully Subscribed!

Open chat