Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions C++/Program -1/Program.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
int main() {
cout<<"Enter the number of elements "<<endl;
int n;
cin>>n;//Input the size of array
int arr[n];
int min=INT_MAX;
int max=INT_MIN;
cout<<"Enter the elements"<<endl;
for(int i=0;i<n;++i)//Input the elements of array
{
cin>>arr[i];
if(arr[i]<min)//if current element is less than min
min=arr[i];//min is updated
if(arr[i]>max)//if current element is greater than max
max=arr[i];//max is updated
}
cout<<"Minimum element is:"<<min<<endl;
cout<<"Maximum element is:"<<max<<endl;
return 0;
}
9 changes: 9 additions & 0 deletions C++/Program -1/README
Original file line number Diff line number Diff line change
@@ -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