5.7.2 Copy And Modify Array Elements

Question: Convert negative elements to 0

Answer: // Convert negatives to 0

for (i = 0; i < NUM_ELEMENTS; ++i) {

if (userVals[i] < 0) {

userVals[i] = 0;

}

}

Question:

Answer:

Question: double each number in a array

Answer: for(i=0; i < NUM_ELEMENTS; ++i){

userVals[i] = userVals[i]*2;

}

Question: 10.7.2 Array copying: Converting negative to 0

Answer: // Convert nums to newNums

for (i = 0; i < NUM_ELEMENTS; ++i) {

copiedVals[i] = userVals[i];

}

Question:

Answer:

Donation Page

Support Our Work

Do you appreciate the value this website provides? If so, please consider donating to help keep it running. Your donation will go a long way in helping us continue to provide the same quality of content and services. Every bit helps, and your support is greatly appreciated. Thank you for your generosity.