Skip to content

Commit

Permalink
Merge pull request #6997 from sulaemanahmed/patch-7
Browse files Browse the repository at this point in the history
Update Maximum & minimum element.cpp
  • Loading branch information
ossamamehmood authored Nov 7, 2023
2 parents 30cd255 + 3aae22d commit acdaa03
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions Add Code Here/C++/Arrays/Maximum & minimum element.cpp
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
#include<iostream>
#include <iostream>

using namespace std;

int main(){

int a[5]={4,3,6,8,5};
int i;
int max=a[0] ;
int min=a[0];

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

if(a[i]>max){

max=a[i];

}

else if(a[i]<min){

min=a[i];

}
}
cout<<max<<endl;
cout<<min<<endl;
return 0;

int main() {
int a[5] = {4, 3, 6, 8, 5};
int i;
int max = a[0];
int min = a[0];

for (i = 1; i < 5; i++) {
if (a[i] > max) {
max = a[i];
} else if (a[i] < min) {
min = a[i];
}
}

cout << "Maximum element: " << max << endl;
cout << "Minimum element: " << min << endl;

return 0;
}

0 comments on commit acdaa03

Please sign in to comment.