Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

Students also viewed these Databases questions

Question

manageremployee relationship deteriorating over time;

Answered: 1 week ago