In: Computer Science
The program is done in C with tested code.
#include <stdio.h>
int countNumbers(int *x)
{
//counter
int count = 0;
//length of the array
int len = sizeof(x)/sizeof(x[0]);
//loop to pass through the array
for(int i = 0 ;i < len ; ++i )
{
//condition check
if (x[i]>=70 && x[i]<=90)
{
//Updation statement if condition is true
count+=1;
}
}
//returns the final count
return count;
}
int main()
{
//size of the array
int n=5;
//array decleration
int x[n];
//loop to assign values to the elements of the array
for(int i =0;i<n;++i)
{x[i] = 70 + 5*i;}
//formatted print and call of function is merged.
printf("The count of numbers in the array between 70 and 90 (both inclusive) are %i",countNumbers(x));
return 0;
}
The result:
"The count of numbers in the array between 70 and 90 (both inclusive) are 2"