#Why does my message repeat when I don't want it to?
1 messages · Page 1 of 1 (latest)
we're going to need more info. #📄・posting-guidelines
Okay so basically what I'm trying to do is make it so when a set on integers are input I have to first, cout all of the integers except for the one that's the minimum, then once all those are output i also output the minimum, the issue i'm running into is that the minimum will either keep repeating in the middle of the output or at the wrong spot.
can you provide us the code/what you've tried?
I'm sorry I finally figured out what the problem was but I do have another question, this time i'm trying to make a sequence where it reads each integer, if they equal 10 then you output "Fully Complient" and if they don't all equal 10 then you output "Non matching Values," Most of the tests are working except for one and i'm not quite sure why.
#include <iostream>
using namespace std;
int main() {
int numVals;
double fullyCompliant;
int i;
cin >> numVals;
for (i = 0; i <= numVals; ++i) {
if (numVals == 10) {
fullyCompliant = true;
}
else {
fullyCompliant = false;
}
cin >> numVals;
}
if (fullyCompliant) {
cout << "Fully compliant" << endl;
}
else {
cout << "Non-matching value(s)" << endl;
}
return 0;
}
Special character legend
Input
7
10 10 9 10 10 10 10
Your output
Fully compliant
Expected output
Non-matching value(s)
That...makes little sense
Why are you reusing a variable in such a way that it's going to behave unpredictably? Also, you are resetting your compliance inappropriately
You have data type mismatch for your fullyCompliant variable. You declare it as a double but assign a Boolean to it. Also, always initialize your declaration.