This is a C++ program from Object oriented programming using C++ Write a program
ID: 3551285 • Letter: T
Question
This is a C++ program from Object oriented programming using C++
Write a program that accepts 10 values from the user at the keyboard and stores them in an array. Pass the array and its size to a function that determines and displays the smallest and largest of the 10 values. save as SmallAndLarge.cpp
*****Please only use the things that are in the first 6 chapters of the book. Please do not use code that has not been learned in the first six chapters. Points will be awarded promptly once the correct answer is recieved.
Explanation / Answer
#include<iostream>
using namespace std;
void getMinMax(int arr[],int n){
int mn,mx;
mn = mx = arr[0];
for(int i=1;i<n;i++){
if(arr[i]<mn)
mn = arr[i];
if(arr[i]>mx)
mx = arr[i];
}
cout<<"Minimum number: "<<mn<<endl;
cout<<"Maximum number: "<<mx<<endl;
}
int main(){
int t,arr[10];
for(int i=0;i<10;i++){
cout<<"Enter number "<<i+1<<" : ";
cin>>arr[i];
}
getMinMax(arr,10);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.