Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started