Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int max=INT_MIN,max2=INT_MIN,i,j;
- int a[5];
- cout<<"Enter the value"<<endl;
- for(i=0;i<=4;i++){
- cin>>a[i];
- }
- for(i=0;i<=4;i++){
- if(max<a[i]){
- max=a[i];
- }
- }
- for(j=0;j<=4;j++){
- if(max2<a[j]&&a[j]!=max){
- max2=a[j];
- }
- }
- cout<<"Maximum value is = "<<max<<endl;
- cout<<"Second Maximum value is = "<<max2<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment