Question

In: Computer Science

declare an integer array of n numbers //enter a value for n before the declaration enter...

declare an integer array of n numbers //enter a value for n before the declaration

enter values for the declared array, pass the array to the method that has the name "countNumbers"

let the function countNumber count how many elements of the array in the interval
[70 90] means between 70 and 90 inclusive, returns this count to the main, and prints it using format printing.

---------------
Please Solve As soon as
Solve quickly I get you thumbs up directly
Thank's
Rawan F

Solutions

Expert Solution

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"


Related Solutions

In C programming, Thank you Declare an array that can contain 5 integer numbers. Use a...
In C programming, Thank you Declare an array that can contain 5 integer numbers. Use a for loop to ask the user for numbers and fill up the array using those numbers. Write a program to determine the 2 largest integers in the array, and print those numbers. Hint: You can declare integer variables “largest” and “secondLargest” to keep track as you make comparisons using the if...elseif statement. The following is an example of how your program should look when...
C++ Program 1. Declare an integer static array a[ ] with 100 elements. 2. Declare an...
C++ Program 1. Declare an integer static array a[ ] with 100 elements. 2. Declare an integer pointer p. 3. Let p pointing to the array a[ ]. 4. Use p (you have to use p) to put 0 into the first element of this array, 2 into the second element, 4 into the 3rd element, 6 into the 4th element, ... 198 into the 100th element of this array. 5. Use a (you have to use a) to display...
In C++ Declare an integer array of size 20 and assign the array with 20 randomly...
In C++ Declare an integer array of size 20 and assign the array with 20 randomly generated integers in the range [1, 100]. Shuffle the data in the array so that all numbers smaller than 50 are put before the numbers greater or equal to 50. Note you are not allowed to create any other arrays in the program. Finally, print out the shuffled array. (25 points) #include<iostream> using namespace std; const int NUM = 20; int main() {      ...
Write a C program that asks the user to enter 15 integer numbers and then store them in the array.
Write a C program that asks the user to enter 15 integer numbers and then store them in the array. Then, the program will find the second largest element in array and its index without sorting the array. For example, In this array {-55,-2,1, 2, -3, 0, 5, 9, 13, 1, 4, 3, 2, 1, 0}, the second largest element is 9 [found at index 7].
Declare an integer array of size 20 and assign the array with 20 randomly generated integers...
Declare an integer array of size 20 and assign the array with 20 randomly generated integers in the range [1, 100]. Shuffle the data in the array so that all numbers smaller than 50 are put before the numbers greater or equal to 50. Note you are not allowed to create any other arrays in the program. Finally, print out the shuffled array. (25 points) #include<iostream> using namespace std; const int NUM = 20; int main() {             //...
Radix sortCome up with an unsorted array of numbers (integer array). Sort the numbers in ascending...
Radix sortCome up with an unsorted array of numbers (integer array). Sort the numbers in ascending order and descending order and display them using radix sort. First sort in ascending, then reset the array to its original order and finally sort the array again in descending order. I need this in java language.
Radix sort Come up with an unsorted array of numbers (integer array). Sort the numbers in...
Radix sort Come up with an unsorted array of numbers (integer array). Sort the numbers in ascending order and descending order and display them using radix sort. First sort in ascending, then reset the array to its original order and finally sort the array again in descending order. (Write a C# program)
Radix sortCome up with an unsorted array of numbers (integer array). Sort the numbers in ascending...
Radix sortCome up with an unsorted array of numbers (integer array). Sort the numbers in ascending order and descending order and display them using radix sort. First sort in ascending, then reset the array to its original order and finally sort the array again in descending order. I need this in java language. Radix Sort assignment (CISP430 ignore this part) This is only for those who are using Java How many classes do I need? A: Node, Queue, Radix, Driver...
Radix sort Come up with an unsorted array of numbers (integer array). Sort the numbers in...
Radix sort Come up with an unsorted array of numbers (integer array). Sort the numbers in ascending order and descending order and display them using radix sort. First sort in ascending, then reset the array to its original order and finally sort the array again in descending order. C++ program thanks
Write a C program to Declare an integer array of size 10 with values initialized as...
Write a C program to Declare an integer array of size 10 with values initialized as follows. int intArray[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; Compute each item of a new array of same size derived from the above array by: adding first item (intArray[0]) of the array with 3rd, 2nd with 4th, 3rd with 5th and so on. For the last-but-one item intArray[8], add it with first item and for the last item (intArray[9])...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT