im making a program that has two arrays. This program takes input from user and puts into the arrays using for statements. After all numbers entered its suppose to add them together and print that using another for statement... the program compiles but has runtime/semantic errors.
ps: using g++ compiler from terminal and also using terminal editor utility
here is the code
your problem statement is ambiguous, however it is still clear there are code bugs.
To paraphrase your code:
for every integer I in [ 0..4 ], do the following:
for every integer D in [ 0..4 ], do the following:
read a number into b[ D ]
read a number into a[ I ]
How many times do you read into a[ I ]?
Then look at your loops on 23-29, as it does a similar thing.
You're using nested for loops for both input and output.
By nesting them, they will scan for input and then output 25 times. Perhaps you have wanted to use a 2D array instead of 2 separate arrays?
Can you define your problem more clearly? What do you mean by add them together? Do you mean summation of all elements in each array, or summing corresponding elements in the 2 arrays to form a 3rd array?