hi,
i need some help with adding numbers in array.
the arrays are the same size, but the new array must be the same size as the first two. i know how to add two arrays but i don't know how to make the case for bigger size and say to user that sum is to bigg. for example:

int number1[] = {9,2,3,4,5};
int number2[] = {2,3,4,5,6};

sum[0]=number1[0]+number2[0], sum[1]=number1[1]+number2[1],

any help appreciated:)

Recommended Answers

All 3 Replies

It's a semicolon, not a comma.

You should also use a loop, not leaving it unrolled like that, especially
if you decide to expand the array size latter.

Use a for loop.

That's pretty standard when you have an array, that is to use a for loop to iterate over the elements of the array.

yes, i know how to add them (using for loop), that was for example
but i don't know how to check size of sumed array

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.