Double any element’s value that is less than minval.

in C++ 1) twice any factor’s worth this is certainly significantly less than minVal. Ex: If
minVal = 10, after that dataPoints = {2, 12, 9, 20} becomes {4, 12, 18,
20} Ex: Testing minVal = 4 and dataPoints = {1, 2, 3, 4, 5, -3}
becomes {2 4 6 4 5 -6} #include
utilizing namespace std; int main() {
const int NUM_POINTS = 4;
int dataPoints[NUM_POINTS];
int minVal = 0;
int i = 0; dataPoints[0] = 2;
dataPoints[1] = 12;
dataPoints[2] = 9;
dataPoints[3] = 20; minVal = 10; // pupil signal right here for (i = 0; i < NUM_POINTS; ++i) { cout << dataPoints[i] << " " ; } cout << endl; return 0; } 2) create a cycle that subtracts 1 from each aspect in lowerScores. If factor had been 0 or unfavorable, assign 0 to the factor. Ex: lowerScores = {5, 0, 2, -3} becomes {4, 0, 1, 0}. #include
utilizing namespace std; int main() {
const int SCORES_SIZE = 4;
int lowerScores[SCORES_SIZE];
int i = 0; lowerScores[0] = 5;
lowerScores[1] = 0;
lowerScores[2] = 2;
lowerScores[3] = -3; /* Your option goes right here */ for (i = 0; i < SCORES_SIZE; ++i) { cout << lowerScores[i] << " "; } cout << endl; return 0; } 3)Add each aspect in origList utilizing the matching worth in offsetAmount. Print each amount accompanied by an area. Ex: If origList = {40, 50, 60, 70} and offsetAmount = {5, 7, 3, 0}, printing: 45 57 63 70 #include
utilizing namespace std; int main() {
const int NUM_VALS = 4;
int origList[NUM_VALS];
int offsetAmount[NUM_VALS];
int i = 0; origList[0] = 40;
origList[1] = 50;
origList[2] = 60;
origList[3] = 70; offsetAmount[0] = 5;
offsetAmount[1] = 7;
offsetAmount[2] = 3;
offsetAmount[3] = 0; /* Your option goes right here */ cout << endl; return 0; }

1.
#include
utilizing namespace std;
int main() {
const int NUM_POINTS = 4;
int dataPoints[NUM_POINTS];
int minVal = 0;
int i = 0;
dataPoints[0] = 2;
dataPoints[1] = 12;
dataPoints[2] = 9;
dataPoints[3] = 20;
minVal = 10;
for(i = 0; i < NUM_POINTS; i++) if(dataPoints[i] < minVal) dataPoints[i] *= 2; for (i = 0; i < NUM_POINTS; ++i) { cout << dataPoints[i] << " " ; } cout << endl; return 0; } 2. #include
utilizing namespace std;
int main() {
const int SCORES_SIZE = 4;
int lowerScores[SCORES_SIZE];
int i = 0;
lowerScores[0] = 5;
lowerScores[1] = 0;
lowerScores[2] = 2;
lowerScores[3] = -3;
for(i = 0; i < SCORES_SIZE; i++) if(lowerScores[i] > 0)
lowerScores[i]–;
else
lowerScores[i] = 0;
for (i = 0; i < SCORES_SIZE; ++i) { cout << lowerScores[i] << " "; } cout << endl; return 0; } 3. #include
utilizing namespace std;
int main() {
const int NUM_VALS = 4;
int origList[NUM_VALS];
int offsetAmount[NUM_VALS];
int i = 0;
origList[0] = 40;
origList[1] = 50;
origList[2] = 60;
origList[3] = 70;
offsetAmount[0] = 5;
offsetAmount[1] = 7;
offsetAmount[2] = 3;
offsetAmount[3] = 0;
for(i = 0; i < NUM_VALS; i++) cout<

Leave a Comment