60 475
Assignments Done
98,1%
Successfully Done
In April 2018

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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions