1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kozerog [31]
3 years ago
15

write a function that counts the number of times the value of y occurs in the first n values in array x. y is an integer variabl

e, x is an array of integers, and n is an integer variable. the name of the function must be count. the parameters must appear in the order of y, x, n.
Computers and Technology
1 answer:
mixer [17]3 years ago
7 0

Answer:

Following are the function of count:

void count(int y,int x[],int n) // function definition of count

{

int k,count=0;  // variable declaration

for(k=0;k<n;++k) // iterating over the loop

   {

   if(x[k]==y) //check the conndition number of times the value of y occurs

   {

   count++; // increment of count by 1

   }

   }

Explanation:

Following are the code in c language

#include <stdio.h> // header file  

void count(int y,int x[],int n) // function definition of count

{

int k,count=0;  // variable declaration

for(k=0;k<n;++k) // iterating over the loop

   {

   if(x[k]==y) //check the conndition number of times the value of y occurs

   {

   count++; // increment of count by 1

   }

   }

   printf(" the number of times the value of y occurs :%d",count); // display count value

   }

int main() // main method

{

   int x[100],y,n,k; // variable declarartion

   printf(" Enter the number of terms n :");

   scanf("%d",&n); // input the terms

   printf(" Enter the array x :");

   for(k=0;k<n;++k) // input array x

   {

   scanf("%d",&x[k]);

   }

   printf("Enter the value of y:");

   scanf("%d",&y);// input value y by user

    count(y,x,n); // calling function

   return 0;

}

In the given program we declared an array x ,variable  y and n respectively Input the array x ,y,n  by user after that we call the function count .In the count function we iterate the loop from o position to array length-1 and check the number of times the value of y occurs by using if statement  i.e  if(x[k]==y) if the condition of if block is true then we increment the count variable Otherwise not .Finally display the count variable which describe the number of count.

Output

Enter the number of terms n :5

1

2

2

56

5

Enter the value of y:2

the number of times the value of y occurs :2

Enter the number of terms n :5

1

2

3

56

5

Enter the value of y:26

the number of times the value of y occurs :0

You might be interested in
10^4+10-2=<br>10^4+10-2=
yaroslaw [1]
10008 is the answer to your question
4 0
3 years ago
Read 2 more answers
Phoebe has to give a presentation about recycling. Where should she look while presenting?
Naddika [18.5K]
Well, I think that maybe the answer is B or C. She shouldn't only look at her presentation while she is presenting it, that doesn't look professional, and you want to look at the people you are talking to.
6 0
3 years ago
Read 2 more answers
What does government office means?​
german

Answer:

   1.    a building or set of rooms in which the business of a department of government administration is carried out.

   "The government offices were dispersed throughout the city"

   2.  a post or position within a country's government.

   "he cannot be the city attorney because he already holds a government office"

Explanation:

4 0
2 years ago
Amelia wants to create a website using the Python computer language to code her site. She will also use CodeSkulptor3 to help he
pishuonlain [190]

Amelia wants to create a website using the Python computer language to code her site. She will also use CodeSkulptor3 is an example of browser-based code editor. The correct option is A.

<h3>What is python?</h3>

Python is a programming language generally used to make websites and software.  Automated tasks and data analysis are also carried out using python.

CodeSkulptor3 is also a browser-based Python interpreter.  It has implemented a subset of Python 3.

Thus, CodeSkulptor3 is an example of browser-based code editor. The correct option is A.

Learn more about python.

brainly.com/question/19045688

#SPJ1

3 0
2 years ago
Why should you avoid the use of sarcasm cliches and idioms in busniess letters?
Oliga [24]
You would not be taken as seriously as you should be by other businesses.
3 0
3 years ago
Read 2 more answers
Other questions:
  • What is a mortgage?
    8·2 answers
  • How can our perceptions help us to choose the channel for our message?
    5·1 answer
  • Complete the following table.
    6·1 answer
  • You change a document that is saved on your computer by cutting text from the document what happens to the text when you preform
    5·1 answer
  • Which of these is an expansion slot type?
    5·1 answer
  • Hazel has just finished adding pictures to her holiday newsletter. She decides to crop an image. What is cropping an image?
    10·1 answer
  • When calling a function with arguments that should be modified, the __________ of those arguments are passed.
    5·1 answer
  • What is a task that is not associated with loading existing data into a new ERP system.
    11·2 answers
  • Class C Airspace inner ring begins at the __________ and extends vertically (by definition) to MSL charted values that generally
    5·1 answer
  • Explain the measures put in place in order to maintain each of the element of computer security<br>​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!