Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Use visual studio 2015. *write a program that uses an array declaration stat

ID: 3836066 • Letter: C

Question

C++ Use visual studio 2015. *write a program that uses an array declaration statement to initialize the following numbers in an array named slopes:17.24,25.63,5.94,33.92,3.71,32.84,35.93,18.24 and 6.92.your program should locate an display the maximum and minimum in the array. C++ Use visual studio 2015. *write a program that uses an array declaration statement to initialize the following numbers in an array named slopes:17.24,25.63,5.94,33.92,3.71,32.84,35.93,18.24 and 6.92.your program should locate an display the maximum and minimum in the array. Use visual studio 2015. *write a program that uses an array declaration statement to initialize the following numbers in an array named slopes:17.24,25.63,5.94,33.92,3.71,32.84,35.93,18.24 and 6.92.your program should locate an display the maximum and minimum in the array.

Explanation / Answer

#include <iostream>
using namespace std;
int main()
{
double slopes[] = {17.24,25.63,5.94,33.92,3.71,32.84,35.93,18.24 ,6.92};
int n = sizeof(slopes) / sizeof(double);
double max = slopes[0];
double min = slopes[0];
for(int i=0;i<n;i++) {
if(max < slopes[i]){
max = slopes[i];
}
if(min > slopes[i]){
min = slopes[i];
}
}
cout<<"Max value: "<<max<<endl;
cout<<"Min value: "<<min<<endl;
return 0;
}

Output:

sh-4.2$ g++ -o main *.cpp                                                                                                                                                                                                                                              

sh-4.2$ main                                                                                                                                                                                                                                                           

Max value: 35.93                                                                                                                                                                                                                                                       

Min value: 3.71

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote