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
Compare computer virus and worm ​
Zina [86]

Answer:

You can say they're somewhat alike, since a worm wiggles into a tight spot, just like how a computer virus wiggles into your computer-

Hope this helps-

7 0
3 years ago
Read 2 more answers
An operating system can be categorized according to: question 1 options:
9966 [12]

Answer:

An operating system can be categorized according to both the given options. Thus answer is option C

Explanation:

An operating system should support multiple logins. Because the login plays a major role and that is the need and mainly in the organization where one system will be shared by multiple users. Also, Operating system should perform multi-tasking. This efficiency is required so that the user completes the work very faster and he need not wait to go for the next task.

For example an operating system handles user’s task, background tasks, keep track of the status of the devices, allots output device to the requested user and so on.  

5 0
3 years ago
Read 2 more answers
public class Parent { private int value = 100; public int getValue() { return value; } } public class Child extends Parent { pri
Shalnov [3]

The answer & explanation for this question is given in the attachment below.

3 0
3 years ago
What is a Layer 2 device that receives an electrical signal in one port, interprets the bits, and makes a filtering or forwardin
iren2701 [21]

Answer:

Router

Explanation:

Router -

It is a networking device which helps to forward the data packets between the networks of the computer .

It acts as a traffic director in the internet .

The data which is sent via internet is made into data packets . And then the packet is forwarded from one router to another , until the packed reaches its destination .

The function given in the question is about router .

5 0
3 years ago
Having knowledge of the main parts of a computer: CPU, ALU, INPUT, OUTPUT ,and MEMORY Can you explain in simple for dummies what
Morgarella [4.7K]

Answer:

Explanation:

Great question, it is important to ask these questions in order to get rid of any doubts you may be having.

I will explain this as simply as possible in separate parts.

CPU: the CPU is the brain of the computer where all the information is received, processed, and sent from.

ALU: are the digital circuits inside the CPU used to perform all the arithmetic and logic operations

INPUT: are the commands given to the computer by the user.

OUTPUT: is the information displayed on the screen by the computer.

Memory: is the piece of hardware used to save all the information that is currently being used by the computer.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

5 0
3 years ago
Other questions:
  • After doing the route tracing to a particular IP addresses, paste the path of IP addresses that were taken from your IP address
    13·1 answer
  • Can I change my brainly username?
    9·2 answers
  • Assume you have written a method with the header num mymethod(string name, string code). the method's type is
    5·1 answer
  • How to Save Power-Point presentation as a single file Web page that can be uploaded to the World Wide Web ?
    14·1 answer
  • What are some (free) good animation websites (for PC/Microsoft) for a short informational video about homelessness?
    15·1 answer
  • Google’s adwords system provides a quality score as a measure of _____, which indicates the usefulness of an ad message to consu
    6·1 answer
  • Dr. Kim divides a programming class into groups. Each group will create a large program as their
    15·2 answers
  • In unreal engines which class should be used to define the rules of the game
    8·1 answer
  • What is a fire wall and how does it work
    14·1 answer
  • 1. Using a microphone to create an audio file to accompany a message is an example of how data is processed and sent to an outpu
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!