From 3a0002e877d0f9aac8be1c5f8b7608cc3580dbf7 Mon Sep 17 00:00:00 2001 From: jainvaidehi <54447956+jainvaidehi@users.noreply.github.com> Date: Thu, 1 Oct 2020 00:08:16 +0530 Subject: [PATCH 1/2] Created MinMax --- C++/Program -1/Program.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 C++/Program -1/Program.cpp diff --git a/C++/Program -1/Program.cpp b/C++/Program -1/Program.cpp new file mode 100644 index 00000000..9144cf64 --- /dev/null +++ b/C++/Program -1/Program.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; +#include +int main() { + cout<<"Enter the number of elements "<>n;//Input the size of array + int arr[n]; + int min=INT_MAX; + int max=INT_MIN; + cout<<"Enter the elements"<>arr[i]; + if(arr[i]max)//if current element is greater than max + max=arr[i];//max is updated + } + cout<<"Minimum element is:"< Date: Thu, 1 Oct 2020 00:10:54 +0530 Subject: [PATCH 2/2] Created README --- C++/Program -1/README | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 C++/Program -1/README diff --git a/C++/Program -1/README b/C++/Program -1/README new file mode 100644 index 00000000..96603195 --- /dev/null +++ b/C++/Program -1/README @@ -0,0 +1,9 @@ +Program 1 + +Write a program to find the maximum and minimum element in an array. + +Variable description-- +n=Number of elements in an array +arr=Array of size n +min= Holds the minimum element +max=Holds the maximum element