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; }
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;
}
Step by step
Solved in 3 steps with 1 images