#include<iostream>
using namespace std;
int main()
{
{
int size;
cout << "enter size of array : ";
cin >> size;
cout << "enter size of array : ";
cin >> size;
int arra[size];
int smallelement, largestelement;
cout << "\nenter array elements : ";
for (int i = 0; i < size; i++)
{
cin >> arra[i];
}
largestelement = smallelement = arra[0];
for (int i = 0; i < size; i++)
{
if (arra[i] > largestelement)
{
largestelement = arra[i];
}
if (arra[i] < smallelement)
{
smallelement = arra[i];
}
}
cout << "The biggest number is " << largestelement << endl;
cout << "The smallest number is " << smallelement << endl;
for (int i = 0; i < size; i++)
{
cin >> arra[i];
}
largestelement = smallelement = arra[0];
for (int i = 0; i < size; i++)
{
if (arra[i] > largestelement)
{
largestelement = arra[i];
}
if (arra[i] < smallelement)
{
smallelement = arra[i];
}
}
cout << "The biggest number is " << largestelement << endl;
cout << "The smallest number is " << smallelement << endl;
return 0;
}
}
Output :
enter size of array : 10 enter array elements : 12 43 64 97 36 54 23 98 65 46 The biggest number is 98 The smallest number is 12
0 Comments