Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //What looks wrong with this picture? If you can't see the issue you don't know enough about programming yet.
- //Look closely and you'll see what I mean.
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int carrier = 100;
- int num = 20;
- int array[num];
- int array2[num];
- int result[carrier];
- cout << "Enter 20 numbers and I will add" << endl;
- cin >> array[carrier];
- cout << "Enter 20 numbers for the second array" << endl;
- cin >> array2[carrier];
- cout << "Now adding the numbers" << endl;
- result[carrier] = array[carrier] + array2[carrier];
- cout << result[carrier];
- system("pause");
- return 0;
- }
- //Next lets show a way to fix this.
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- const int carrier = 20;
- const int num = 20;
- int array1[num];
- int array2[num];
- int result[carrier];
- for(int T = 0; T < carrier; T++)
- {
- cout << "Enter a number for array one" << endl;
- cin >> array1[T];
- cout << "Enter a number for the second array" << endl;
- cin >> array2[T];
- cout << "Now adding the numbers" << endl;
- result[T] = array1[T] + array2[T];
- cout << result[T] << endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement