Respuesta :
Answer:
The correct program to this question can be given as:
Program:
#include <stdio.h>
int main(void) //define main method.
{
const int NUM_POINTS = 4; //define constant variable and assign value.
int dataPoints[NUM_POINTS]; //define array.
int minVal = 0; //define variable
int i = 0; //define variable
printf("Enter minimum value :"); //message
scanf("%d",&minVal); //input value from user.
printf("Enter array elements :"); //message
for(i = 0;i<NUM_POINTS;++i) //loop.
{
scanf("%d",&(dataPoints[i])); //assign elements in array
}
for (i = 0; i < NUM_POINTS; ++i) //loop
{//conditional statement.
if(dataPoints[i]<minVal) //check condition.
{
dataPoints[i] = 2*dataPoints[i]; //multiply by 2.
}
}
printf("array elements :"); //message
for (i = 0; i < NUM_POINTS; ++i) //loop.
{
printf("%d ", dataPoints[i]); //print array value.
}
return 0;
}
Output:
Enter minimum value :10
Enter array elements :2 12 9 20
array elements :4 12 18 20
Explanation:
The explanation of the above C language program as follows:
- In the program first, we include the header file. Then we define the main method in method we define a variable that is "NUM_POINTS, minVal, dataPoints[] and i".
- The NUM_POINTS variable uses a const key that is used to make variable constant and we assign a value in this variable. Then we define dataPoints[] variable. It is an array type variable that is used to store user inputs and the minVal is an integer variable that is used for user input and checks the value of the array.
- Then we define a three for loops in the first loop we insert array elements from the user.
- In the second loop, we use the condition statement in the if block we compare the value of dataPoints is less than to minVal. If this value is true so, we multiply by 2 in array elements.
- In the third loop, we print all array elements.