using array to find the min and max

Q1: Write a program using array to find the min and max elements of 5 numbers that a user will input.

#include <iostream>
using namespace std;
int main()
{

//Prompt the user to Enter Five numbers

//Find max and main elements of the array, and display the result

return 0;
}


please help me
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include<iostream>
using namespace std;
int main()
{
int a[5] = {3,4,6,1,2};
int max = a[0],i;
for(i=1; i<5; i++)
{
if (a[i]>max)
max = a[i];
}
cout<<endl<<max;
return 0;
}


Do it similarly for minimum
Last edited on
Topic archived. No new replies allowed.