Sep 21, 2014 at 9:44pm UTC
I cant get the output that i want,please help me.
i want the program can show the number it choose.and the array size must be different.(my fd said that the array must be same)
Many thanks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int sum;
do
{
cout << "Enter the sum (0 to 7, 0 to exit):" ;
cin >> sum;
if (cin.fail())
{
cout << "Enter a number! " << endl;
cin.clear();
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n' );
}
if (sum == 0)
{
cout << "END OF PROGRAM" << endl;
return 0;
}
} while (sum < 0 || sum > 7);
double num1[4] = {0,1,2,3};
double num2[2] = {0,4};
sum =num1 +num2;
cout << num1 << endl;
cout << num2 << endl;
}
Last edited on Sep 21, 2014 at 11:52pm UTC
Sep 21, 2014 at 10:28pm UTC
What do you want your sum to be?
Sep 21, 2014 at 11:53pm UTC
i want my sum(input) is 0 to 7(0 to exit)
that the program can pick the number in two array to sum for me.
for example when i input 5
that it will pick 1 from first array and 4 from second array.And i want it show which number it picked from those arrays.