Combined this two program in 1 program in c++ program and use function. Source Code: #include using namespace std; int main() {   int number1, number2, sum;        cout << "Enter two integers: ";   cin >> number1 >> number2;   sum = number1 + number2;   cout << number1 << " + " << number2 << " = " << sum;        return 0; } #include using namespace std; #define SIZE 100 int main() {  int n,i,j, max, min, array[SIZE], size;  int t;    cout<<"Enter total number of elements: ";  cin>>size;    for(i=0;i>array[i];  }    for(i=0;iarray[j])    {     t =array[i];     array[i]=array[j];     array[j]=t;    }   }  }    cout<<"Sorted (Ascending Order) Array elements:"< max)             max = array[i];         if(array[i] < min)             min = array[i];     }     cout<<"\nMaximum element =" << max << "\n";     cout<<"Minimum element =" << min;  return 0;   }

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.1: Function And Parameter Declarations
Problem 11E
icon
Related questions
Question

Combined this two program in 1 program in c++ program and use function.

Source Code:

#include <iostream>
using namespace std;

int main() {

  int number1, number2, sum;
    
  cout << "Enter two integers: ";
  cin >> number1 >> number2;

  sum = number1 + number2;

  cout << number1 << " + " << number2 << " = " << sum;     

  return 0;
}

#include <iostream>
using namespace std;

#define SIZE 100

int main()
{


 int n,i,j, max, min, array[SIZE], size;
 int t;
 
 cout<<"Enter total number of elements: ";
 cin>>size;
 
 for(i=0;i<size;i++)
 {
  cout<<"Enter element ["<<i+1<<"] ";
  cin>>array[i];
 }
 
 for(i=0;i<size;i++)
 {  
  for(j=i+1;j<size;j++)
  {
   if(array[i]>array[j])
   {
    t =array[i];
    array[i]=array[j];
    array[j]=t;
   }
  }
 }
 
 cout<<"Sorted (Ascending Order) Array elements:"<<endl;
 for(i=0;i<size;i++)
  cout<<array[i]<<"\n";
  
    for(i=0; i<size; i++)

    {
        if(array[i] > max)
            max = array[i];
        if(array[i] < min)
            min = array[i];
    }
    cout<<"\nMaximum element =" << max << "\n";
    cout<<"Minimum element =" << min;
 return 0;
 
}

 

 

 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning