Welcome to Westonci.ca, your go-to destination for finding answers to all your questions. Join our expert community today! Get detailed and precise answers to your questions from a dedicated community of experts on our Q&A platform. Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A platform.
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
We hope this information was helpful. Feel free to return anytime for more answers to your questions and concerns. We hope our answers were useful. Return anytime for more information and answers to any other questions you have. Get the answers you need at Westonci.ca. Stay informed by returning for our latest expert advice.