Double any element's value that is less than minVal. Ex: If minVal = 10, then dataPoints = {2, 12, 9, 20} becomes {4, 12, 18, 20}.
#include <stdio.h>
int main(void) {
const int NUM_POINTS = 4;
int dataPoints[NUM_POINTS];
int minVal;
int i;
dataPoints[0] = 2;
dataPoints[1] = 12;
dataPoints[2] = 9;
dataPoints[3] = 20;
minVal = 10;
/* Your solution goes here */
for (i = 0; i < NUM_POINTS; ++i) {
printf("%d ", dataPoints[i]);
}
printf("\n");
return 0;
}
C Program:
#include <stdio.h>
int main(void) {
const int NUM_POINTS = 4;
int dataPoints[NUM_POINTS];
int minVal;
int i;
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*dataPoints[i];
}
for (i = 0; i < NUM_POINTS; ++i) {
printf("%d ", dataPoints[i]);
}
printf("\n");
return 0;
}
Double any element's value that is less than minVal. Ex: If minVal = 10, then dataPoints...
Double any element's value that is less than minValue. Ex: If minValue 10, then dataPoints = {2, 12, 9, 20) becomes {4, 12, 18, 20). public static void main (String ] args) { Scanner scnr = new Scanner(System.in); 4 5 final int NUM_POINTS = 4; int dataPoints = int minValue int i new int[NUM POINTS]; 7 8 minValue 10 scnr.nextInt(); 11 for (i 0; i dataPoints[i] } dataPoints.length; ++i) { scnr.nextInt); 12 13 14 15 /Your solution goes here */...
in C++ Problem: Subtract 4 to any element's value that is greater than maxVal. Ex: If maxVal = 10, then dataPoints = {2, 12, 9, 20} becomes {2, 8, 9, 16}. ------------------------ #include #include using namespace std; int main() { int maxVal; int NUM_POINTS; unsigned int i; cin >> maxVal; cin >> NUM_POINTS; vector dataPoints(NUM_POINTS); for (i = 0; i < dataPoints.size(); ++i) { cin >> dataPoints.at(i); } /* Your solution goes here */ for (i = 0; i <...
For any element in keysList with a value greater than 50. print the corresponding value in itemsList, followed by a comma (no spaces) Ex: If the input is 32 105 101 35 10 20 30 40 the output is 20,30, 1 include <stdio.h> 2 3 int main(void) { 4 const int SIZE LIST - 4 5 int keysList[SIZE LISTI: 6 int itemslist[SIZE_LIST); 7 int 1; 8 9 scanf("%d", &keysList[0]); 10 scanf("%d", &keyslist[1]); 11 scanf("%d", &keysList[2]); 12 scanf("%d", &keysList[]); 13 14...
for c CHALLENGE ACTIVITY 9.7.1: Decrement array elements. Write a loop that subtracts 1 from each element in lowerScores. If the element was already 0 or negative, assign 0 to the element. Ex lowerScores = {5,0,2,-3) becomes {4.0, 1.0). 1 include <stdio.h> 3 int main(void) 0 const int SCORES_SIZE - 4; int lowerScores [SCORES_SIZE]: int i; for (1 - 0; i < SCORES_SIZE; ++) { scanf("%d", &(lowerScores[i])); /" Your solution goes here / { 15 for (i = 0; i...
IN C PLEASE Find the maximum value and minimum value in miles Tracker. Assign the maximum value to maxMiles, and the minimum value to minMiles. Sample output for the given program: Min miles: -10 Max miles: 40 (Notes) 1 tes pass ㄷ Alltes int j; 1 #include <stdio.h> 2 3 int main(void) { 4 const int NUM_ROWS = 2; 5 const int NUM_COLS = 2; 6 int milesTracker [NUM_ROWS] [NUM_COLS]; 7 int i; 8 9 int maxMiles = 0; //...
In C please Write a function so that the main() code below can be replaced by the simpler code that calls function MphAndMinutesToMiles(). Original maino: int main(void) { double milesPerHour, double minutes Traveled; double hours Traveled; double miles Traveled; scanf("%f", &milesPerHour); scanf("%lf", &minutes Traveled); hours Traveled = minutes Traveled / 60.0; miles Traveled = hours Traveled * milesPerHour; printf("Miles: %1f\n", miles Traveled); return 0; 1 #include <stdio.h> 3/* Your solution goes here */ 1 test passed 4 All tests passed...
coding in C Programming Assign the size of userInput to stringSize. Ex: if userInput = "Hello", output is: Size of userInput: 5 #include < stdio.h > #include < string.h > int main(void) { char userlnput[50] = "": int stringSize = 0: strcpy(userInput, "Hello"): /* Your solution goes here */ printf("Size of userlnput: %d\n", stringSize): return 0: }
i have no idea how to do floating point comparison this is c programming CHALLENGE 3.16.1: Floating-point comparison: Print Equal or Not equal Write an expression that will cause the following code to print "Equal" if the value of sensorReading is "close enough" to targetValue. Otherwise, print "Not equal". Ex: If targetValue is 0.3333 and sensorReading is (1.0/3.0), output is Equal 1 #include <stdio.h 2 #include <math.h> 4 int main(void)f 6 8 scanf("%lf", &targetValue); 1 test passed double targetValue; double...
CHALLENGE ACTIVITY 5.71 String library functions. Assign the size of userinput to stringSize. Ex: if userinput is 'Hello output is: Size of user Input: 5 1 #include <stdio.h> 2 #include <string.h> 4 int main(void) { char user Input[50]; int stringSize; BO scanf("%s", userInput); /* Your solution goes here" printf("Size of user Input: %d\n", stringsize); return ; Run
In C Set hasDigit to true if the 3-character passCode contains a digit. 1 #include «stdio.h> 2 #include«string.h> 3 #include «stdbool.h 4 #include<ctype.h> 6 int main(void) 7 bool hasDigit; 8 char passCode501; 10 11 12 hasDigit false; scanf("%s", &passcode); 13 Your solution goes here * 14 15 if (hasDigit) 16 printf("Has a digit.n 4 #include <ctype.h> 6 int main (void) 1 8 char passCode [50]; bool hasDigit; hasDigit- false; 10 11 scanf("%s",&passcode); 12 13 14 15 if (hasDigit) 16 17...