sahadat49

Maximum

Nov 28th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int max=INT_MIN,max2=INT_MIN,i,j;
  6. int a[5];
  7. cout<<"Enter the value"<<endl;
  8. for(i=0;i<=4;i++){
  9. cin>>a[i];
  10. }
  11. for(i=0;i<=4;i++){
  12. if(max<a[i]){
  13. max=a[i];
  14. }
  15. }
  16. for(j=0;j<=4;j++){
  17. if(max2<a[j]&&a[j]!=max){
  18. max2=a[j];
  19. }
  20. }
  21. cout<<"Maximum value is = "<<max<<endl;
  22. cout<<"Second Maximum value is = "<<max2<<endl;
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment