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
Susan has always wanted to be a veterinarian. When doing her research, she answers all self-assessments geared toward that caree
kherson [118]
She should be researching every component towards a veterinarian
5 0
3 years ago
Write a program in Python that reads in investment amount, annual interest rate, and number of years, and displays the future in
pickupchik [31]

Answer:

investmentAmount = float(input("enter the investment amount: "))

annualInterestRate = float(input("enter the Annual Interest Rate: "))

numYears = int(input("Enter NUmber of Years: "))

monthlyInterestRate = annualInterestRate/12

futureInvestmentValue = investmentAmount * (1 + monthlyInterestRate)*(numYears*12)

print("The Future Investment Value is: ")

print(futureInvestmentValue)

Explanation:

Using python programming language as required, we use the input function to prompt user for inputs for each of the variables.

There is a conversion from the variable annualInterestRate  to monthlyInterestRate before the formula for the futureInvestmentValue is applied

4 0
3 years ago
3 Points
tino4ka555 [31]

Answer:

its B the person in the comments were right

Explanation:

took an edge test

6 0
3 years ago
All of the following items could be too expensive for someone with only a high school degree to afford except
Papessa [141]
This sounds like a multiple choice answer can I have 4 choices to pick?
7 0
3 years ago
Which of the following is NOT an option in the comments group
IgorLugansk [536]
I need the options to help you out, thanks. :)
4 0
3 years ago
Other questions:
  • What is a negative impact of digital communication
    6·1 answer
  • The amount of data is increasing exponentially over time. true or false.
    6·1 answer
  • Data arranged and stored in a data set
    9·1 answer
  • What provides quality education for students
    14·1 answer
  • In JAVA,
    10·1 answer
  • A tablet computer transmits a file over a wi-fi link to an access point.
    13·1 answer
  • For which type of long-distance call do you need to tell the operator the name of the person to whom you wish to speak?
    10·1 answer
  • Data flow is not a major consideration when building an analytics model. T/F
    13·1 answer
  • To change the way a slide moves from one slide to the next, what tab should be selected?
    12·1 answer
  • PLEASE HELP! I accidently looked up a link, and now this same link keeps popping up everywhere, how do I stop this!?!? please he
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!