Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

C Add Function with an Array


Scar0ptics's Avatar
Member
0 0

Create an AddOneToAll function so that it correctly adds one to each element in an array with 5 elements: Compile your code with a Linux compiler and execute the output file. "./"

Output: 10 20 30 40 50 11 21 31 41 51


Scar0ptics's Avatar
Member
0 0

int main (int argc, char **, argv) {

int array [5]; addOneToAll(array, 5); } void addOneToAll ( int * array, int count) { //add one to all

for (int x = 0; x<count; x++) { array[x] = array [x] + 1;

}

// I understand that there are other ways of doing this and I am open to all constructive criticism, but before you comment please consider that this code is written so the built-in Linux compiler (g++) can understand it.