# Answer to Question #3320 in C++ for mukunda

Question #3320

Write a program to find the biggest and smallest numbers in the array?

Expert's answer

#include <iostream>

using namespace std;

int main()

{

const int N = 5;

int arr[N] = { 10, 46, -37, 8, 19 };

int smallest = 0, biggest = 0;

for (int i = 1; i < N; ++i) {

if (arr[smallest] > arr[i])

smallest = i;

if (arr[biggest] < arr[i])

biggest = i;

}

cout << "The smallest number in the array is " << arr[smallest] << endl;

cout << "The biggest number in the array is " << arr[biggest] << endl;

return 0;

}

using namespace std;

int main()

{

const int N = 5;

int arr[N] = { 10, 46, -37, 8, 19 };

int smallest = 0, biggest = 0;

for (int i = 1; i < N; ++i) {

if (arr[smallest] > arr[i])

smallest = i;

if (arr[biggest] < arr[i])

biggest = i;

}

cout << "The smallest number in the array is " << arr[smallest] << endl;

cout << "The biggest number in the array is " << arr[biggest] << endl;

return 0;

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment