Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I cant figure out how to get the values to display again after adding an additio

ID: 3653705 • Letter: I

Question

I cant figure out how to get the values to display again after adding an additional value to the array. #include #include int main() { int i; int *value; value = (int *) malloc(5 * sizeof(int)); for(i = 0; i < 5; i++) { printf("Enter a value: "); scanf("%d", &value[i]); } printf("Here are the values you have entered: "); for (i = 0; i < 5; i++) printf("%d ", value[i]); printf("Please enter one more value: "); scanf("%d"); for (i = 0; i < 5; i++) printf("%d ", value[i]); printf("These are all the values that you have entered: "); system("pause"); return 0; }

Explanation / Answer

#include #include int main() { int i; int *value; value = (int *) malloc(6 * sizeof(int));//memory allocating for 6 integers for(i = 0; i < 5; i++) { printf("Enter a value: "); scanf("%d", &value[i]); } printf("Here are the values you have entered: "); for (i = 0; i < 5; i++) printf("%d ", value[i]); printf("Please enter one more value: "); scanf("%d",&value[5]);//taking extra value for (i = 0; i < 6; i++) printf("%d ", value[i]); printf("These are all the values that you have entered: "); system("pause"); return 0; }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote