please follow the instruction above and make changes in following program. Lab 8
ID: 3727492 • Letter: P
Question
please follow the instruction above and make changes in following program.
Explanation / Answer
//Largest.h
double Largest(double numbers[], int size);
//Smallest.h
double Smallest(double numbers[], int size);
//Largest.cpp
#include "Largest.h"
namespace NLC
{
double Largest(double numbers[], int size)
{
double max = numbers[0];
for (int i = 0; i < size; i++)
{
if (numbers[i] > max)
max = numbers[i];
}
return max;
}
}
//Smallest.cpp
#include "Smallest.h"
namespace NLC
{
double Smallest(double numbers[], int size)
{
double min = numbers[0];
for (int i = 0; i < size; i++)
{
if (numbers[i] < min)
min = numbers[i];
}
return min;
}
}
//main.cpp
#include<iostream>
#include "Largest.cpp"
#include "Smallest.cpp"
using namespace std;
int main(){
double numbers[] = {4.5, 3.4, 5.6, 9.1, 6.7,7.8};
int count = sizeof(numbers)/sizeof(double);
cout<<NLC::Largest(numbers, count)<<endl;
cout<<NLC::Smallest(numbers, count)<<endl;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.