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
Reading is the process of transferring data, instructions, and information from memory to a storage medium.
maksim [4K]
True, the computer will read from, say, a blu-ray and then transfer it to your RAM to before writing it to your hard drive and then, through the various other wonders of computers, it can be displayed on your monitor.
8 0
4 years ago
Evidence left behind by participants or observers is an example of what kind of resource?
Natasha2012 [34]
The answer should be D
6 0
3 years ago
Read 2 more answers
10 Ejemplos de Software de Sistema. AYUDENME POR FAVOR SE LOS SUPLICO
bearhunter [10]

Answer:

MacOS, Linux, Android, Microsoft Windows, software de ciencia computacional, motores de juegos, automatización industrial y aplicaciones de software como servicio.

:-) (-:

6 0
3 years ago
Write. A program to fine the difference of two number 25 and 17 . Also displays the output
Anon25 [30]

Answer:

Answer = 25-17

print("25-17", Answer)

Explanation:

You put the sum into a variable which in this case would be Answer and then you can output it with the question.

6 0
3 years ago
¿Que importancia tienen los sensores para la agricultura?
PSYCHO15rus [73]

Answer:

La agricultura es el cultivo de cultivos y la cría de animales para producir alimentos, combustible, lana y otros productos que proporcionan los artículos que consumimos y utilizamos a diario.

La producción agrícola es una forma de producción que puede tardar hasta un año en completar un proceso desde la siembra hasta la cosecha y, por lo tanto, los sensores juegan un papel importante en la agricultura para el monitoreo y evaluación de cultivos y ganado.

Los tipos de sensores utilizados en la agricultura incluyen;

1) Sensores de ubicación (GPS)

2) Sensores ópticos (cámaras inteligentes) para análisis de suelo de campo remoto y análisis de distribución de plantas

3) Sensores electroquímicos (sensores de pH) que pueden medir el pH de los suelos

4) Sensor acelerómetro utilizado para el mantenimiento predictivo de componentes con partes móviles

5) Sensores mecánicos que determinan el requisito de capacidad de fuerza de un dispositivo que se utilizará en la granja.

6) Sensor de humedad para determinar el contenido de humedad del suelo

Explanation:

6 0
3 years ago
Other questions:
  • Two electronics technicians are looking at the representations of a silver atom and a copper atom in the figure above. Technicia
    10·1 answer
  • You have decided to remove a recently installed feature which method can you use to remove this feature
    13·1 answer
  • What is information associated with a document to help describe that document called?
    12·1 answer
  • What computer is designed to meet the computing needs of several people simultaneously in a small to medium-size business enviro
    5·1 answer
  • The __________ method can determine whether a string contains a value that can be converted to a specific data type before it is
    12·1 answer
  • A ________ is a single media file including art, sound, animation, or movies.
    9·1 answer
  • Discuss two basic types of monitors CRT and LCD give me in short ​
    9·2 answers
  • A variable is assigned a value on line 328 of a program. Which of the following must be true in order for the variable to work?
    12·2 answers
  • Please i need help here.. am giving brainliest.
    11·2 answers
  • (--BRAINLIEST--)<br>Explain the types of secondary memory on the basis of data access.​
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!