for (t = 0; t < 10; ++t)
{
for (i = 0; i < 10; ++i)
since you take in the value for size, you might as well use it here for 10.
for (t = 0; t < 10; ++t)
{
for (i = 0; i < 10; ++i)
since you take in the value for size, you might as well use it here for 10.
Blue
Problem now, it keeps looping.
realize that it is going to say something ~100 times with way you have it set up.
pull the "sorry...." outside of the loop like this
Code:for (t = 0; t < 10; ++t) { for (i = 0; i < 10; ++i) { if (array[t] + array[i] == 100) { cout << "The numbers equal 100.\n"; set = 1; } } if (set==1) cout << "Sorry, I cannot find 2 numbers whose sum is 100.\n"; }
Blue
or even better
Once again this doesn't take into account one number equaling 50. Notice how one number equaling 50 will make it appear that 100 was reached using two different numbers.Code:int set=0; for (t = 0; t < 10; ++t) { for (i = 0; i < 10; ++i) { if (array[t] + array[i] == 100) { cout << "The numbers equal 100.\n"; set++; } } if (set==0) cout << "Sorry, I cannot find 2 numbers whose sum is 100.\n"; else cout << "Found " << set << " sets of numbers whose sum is 100\n." }
I will leave you to the rest....
Blue
I'm getting closer...you've been a great help. I appreciate it.
A final hint on the problem of calculating the value of the same number if it equals 50...
if/then hint: if number 1 is equal to number 2 then it is the same array position... or rather if number 1 is not equal to number 2 then perform desired operation
Blue
thanks betazep, i figured that one out. my only issue now is, I only want it to print one message or the other, not both. everything else checks out - got rid of double hits (two hits on same set of #'s) etc. Think I have the last problem figured out, going to try it now (fingers crossed!).