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]
2 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]2 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
A security administrator is reviewing the following information from a file that was found on a compromised host: Which of the f
Roman55 [17]

Answer:

C. Trojan

Explanation:

In Cybersecurity, vulnerability can be defined as any weakness, flaw or defect found in a software application or network and are exploitable by an attacker or hacker to gain an unauthorized access or privileges to sensitive data in a computer system.

This ultimately implies that, vulnerability in a network avail attackers or any threat agent the opportunity to leverage on the flaws, errors, weaknesses or defects found in order to compromise the security of the network.

In this scenario, a security administrator is reviewing the following information from a file that was found on a compromised host: "cat suspiciousfile.txt."

Some of the ways to prevent vulnerability in a network are;

1. Ensure you use a very strong password with complexity through the use of alphanumerics.

2. You should use a two-way authentication service.

3. You should use encrypting software applications or services.

8 0
2 years ago
In programming, what is a string?
Alla [95]

A way to store a sequence of letters, numbers or symbols.

This is the most accurate statement, though not entirely true.

Hope this helps.

7 0
3 years ago
Read 2 more answers
What should every Software Engineer know about Software Architecture?
Alenkinab [10]
<span>!UML (all of them)
2.Flowchart (more for understanding a real world process of some kind; like a business process)
3.Data model including Bachman (if you don't need to at least understand your data, how it is stored versus a model, i.e., Bachman then you are doing it wrong and your schema could be simplistic)
This is 3 different examples</span>
6 0
3 years ago
Polymorphism means ______________.
Westkost [7]

Answer:

Polymorphism means that a variable of supertype can refer to a subtype object.

Explanation:

For example, in Python programming language, a function that accepts an iterable object uses the concept of polymorphism because that function can accept strings, lists, tuples as arguments.

5 0
3 years ago
Read 2 more answers
Executives of a company deal less with details of the operational activities and deal more with the higher meaningful aggregatio
mylen [45]

Answer:

3. Granularity

Explanation:

Granularity's concept is representing the level of how do we store the data in our database.

If the data are detailed, we can resume the data until get a granularity more strong for our analysis.

For example:

We could store data year by year of our costumers, if want to get more granularity, we could store data month by month, also we could get specific data like how often our customers visit the business or how often our customers buy in a category product.

4 0
3 years ago
Other questions:
  • How does the occupational outlook affect the monetary benefits of a career
    11·1 answer
  • What term is used to describe a function that uses an algorithm to convert an input of letters and numbers into an encrypted out
    9·1 answer
  • White meat and dark meat fish have slightly different nutritional characteristics. What are the nutrition characteristics of dar
    7·2 answers
  • Fill in the blank
    11·1 answer
  • Why are cable networks such as mtv and cnn more profitable than the big four broadcast networks?
    8·1 answer
  • According to your text, three factors are responsible for the rapid rise in new product development. They are faster and more ec
    9·1 answer
  • Write Album's PrintSongsShorterThan() to print all the songs from the album shorter than the value of the parameter songDuration
    14·1 answer
  • In total, how many 8-bit registers are there in the Intel 80x86 CPU design presented in class? Name one of these 8-bit registers
    9·1 answer
  • There is an interface I that has abstract class AC as its subclass. Class C inherits AC. We know that C delegates to an object o
    12·1 answer
  • Demons I shall be your eternal nightmare
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!