Westonci.ca makes finding answers easy, with a community of experts ready to provide you with the information you seek. Find reliable answers to your questions from a wide community of knowledgeable experts on our user-friendly Q&A platform. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.
Sagot :
Answer:
This solution is implemented in C++:
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
double termnum;
cout<<"Terminating number: ";
cin>>termnum;
double num;
vector<double>numbers;
cout<<"Number: ";
cin>>num;
while(num!=termnum){
numbers.push_back(num);
cout<<"Number: ";
cin>>num;
}
double smallest = numbers.at(0);
for(double x:numbers){
if(x < smallest){
smallest = x;
}
}
cout<<"The smallest is "<<smallest;
return 0;
}
Explanation:
This declares the terminating variable as double
double termnum;
The next italicized lines prompts user for terminating value
cout<<"Terminating number: ";
cin>>termnum;
This declares the user input variable as double
double num;
This declares vector of numbers as double
vector<double>numbers;
The next italicized lines prompts user for number
cout<<"Number: ";
cin>>num;
The following iteration is repeated until the terminating value equals the number supplies by the user
while(num!=termnum){
This pushes the number to a vector
numbers.push_back(num);
The italicized lines prompts user for another number
cout<<"Number: ";
cin>>num;
}
This declares and initializes variable smallest
double smallest = numbers.at(0);
The following for loop determines the smallest of the number set
for(double x:numbers){
if(x < smallest){
smallest = x;
}
}
This prints the smallest of the set
cout<<"The smallest is "<<smallest;
return 0;
Also: See attachment
Thank you for trusting us with your questions. We're here to help you find accurate answers quickly and efficiently. We hope you found what you were looking for. Feel free to revisit us for more answers and updated information. Get the answers you need at Westonci.ca. Stay informed with our latest expert advice.