Question: Lab 8 Redo Lab 6 with the following changes: 1. Each function goes in a separate .cpp file. The file name is the name of

Lab 8

Redo Lab 6 with the following changes:

1. Each function goes in a separate .cpp file. The file name is the name of the function.

2. Each function prototype goes in a separate .h file, named as in 1.

3. Each function is defined in the namespace "NLC".

4. Only the main program should remain in the original .cpp file.

5. Modify the main program to include the header files.

6. Modify the main program to account for the namespace you have created.

Checklist

1. Uncheck the Create directory for solution checkbox in the New Project Dialog 2. Project/solution named correctly 3. Correct comments at top 4. Consistent indentation (Use Edit/Advanced/Format Document) 5. Good variable names 6. Overall neat organization 7. Comments in code explain what's being done 8. Each function .cpp file should include the corresponding .h file

THIS IS THE CODE FOR LAB 6

#include "pch.h"

#include

#include

using namespace std;

//Defining protoype since the function will be written outside of main

double Largest(double numbers[], int size); //prototype for largest number

double Smallest(double numbers[], int size); //prototype for smallest number

int main() {

double numbers[] = { 4.5, 3.4, 5.6, 9.1, 6.7, 7.8 };

int count = sizeof(numbers) / sizeof(double);

//Displaying the output

cout << "The largest value in the given array is : " << Largest(numbers, count) << endl;

cout << "The smallest value in the given array is : " << Smallest(numbers, count) << endl;

return 0;

} // end of main function

//Function to get the largest number

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;

}

//Function to get the largest number

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;

}

---------------------------------------------------------------

END OF LAB 6 CODE

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!