Question: Edit this code to print the correct count of the element #include int main() { int arr[100]; int i, n; int count = 0; printf(#

Edit this code to print the correct count of the element

#include

int main() {

int arr[100]; int i, n; int count = 0; printf("# of elements in array: "); scanf("%d", &n); printf("Enter %d array elements ", n);

for (i = 1; i <= n; i++) { printf("Enter element %d: ", i); scanf("%d", &arr[i-1]); }

printf(" Enter a number to count the number of times it occurs in the array: "); scanf("%d", &n);

for (i = 0; i < n; i++) { if (arr[i] == n) { count++; } }

printf("The number of times %d occurs in the array is: %d ", i, count); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!