Question

Given an array of type Real with n temperatures, count all values between low temperature x...

  1. Given an array of type Real with n temperatures, count all values between low temperature x and high temperature y. Hint: use logical operator &&.   C++ CODE PLEASE

Homework Answers

Answer #1
#include<iostream>
using namespace std;
int main(){
        int temps[]={34,45,42,49,24,28,39,43,50,21,25,18,48,36,20};
        int n=15,low,high;
        //reading low and high 
        cout<<"Enter low and high temperature: ";
        cin>>low>>high;
        int count=0;
        //iterating through the array and checking how many are between low and high
        for(int i=0;i<n;i++){
                if(temps[i]>=low && temps[i]<=high)
                        count++;
        }
        cout<<"There are "<<count<<" temperatures between "<<low<<" and "<<high<<endl;
}

NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.

Please Like and Support me as it helps me a lot

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C++ program for : 1. Given an array of real numbers and the dimension n (n...
C++ program for : 1. Given an array of real numbers and the dimension n (n is entered from the keyboard). B form an array, each element bi - arithmetic mean of the array elements and excluding ai. 2. Given an array of integers dimension n. Change the array so that all the elements of the module which is not equal to the maximum element of the array, replaced by zero, and equal - unit. 3. Given an array of...
1. Given an n-element array A, Algorithm X executes an O(n)-time computation for each even number...
1. Given an n-element array A, Algorithm X executes an O(n)-time computation for each even number in A and an O(log n)-time computation for each odd number in A. What is the best-case running time of Algorithm X? What is the worst-case running time of Algorithm X? 2. Given an array, A, of n integers, give an O(n)-time algorithm that finds the longest subarray of A such that all the numbers in that subarray are in sorted order. Your algorithm...
1) Develop a C++ function that determines the average value of an array of type double...
1) Develop a C++ function that determines the average value of an array of type double elements double GetAverage(double array[], int size) The function should accept as input an array of double values The function should accept as input the number of elements in the array of double values The function should return a double value which is the array's average value 2) Develop a C++ function that determines the variance of an array of type double elements double GetVariance(double...
Programming in C: 1. Given the following variable declarations: const size_t n = 50; 2. Write...
Programming in C: 1. Given the following variable declarations: const size_t n = 50; 2. Write the declaration of an an array of pointers to n memory blocks containing 16-bit signed integer values. Use 'x' for the name of the variable. 3. What is the type of the variable x? uint8_t *x[256]; 4. What type does the variable x decay to when used in an expression? uint8_t *x[256] 5. What is the data type of an array of five strings?...
Consider the function f(x,y)= (x+2*y)*e^(x-2y) for all real values (x,y). Determine the linearization to f at...
Consider the function f(x,y)= (x+2*y)*e^(x-2y) for all real values (x,y). Determine the linearization to f at the point (2,1) Use the linearization to approximate f(2.1,1.1)
Create a program on C++ for finding all primes number between two values (inclusive) as sample...
Create a program on C++ for finding all primes number between two values (inclusive) as sample below Sample Input Sample Output 1 10 2 3 5 7 11 20 11 13 17 19 30 40 31 37 NOTES: Please use ARRAY. please show me the code & results. the result must be exactly the same as above, no additional sentences or other stuff. thank you very much
A 512 point DFT X[k] of a real valued sequence x[n] has the following DFT values:...
A 512 point DFT X[k] of a real valued sequence x[n] has the following DFT values: X[0]=20+jα ; X[5] = 20+j30; X[k1]= -10 +j15; X[152] =17+j23; X[k2] = 20-j30; X[k3]=17-j23; X[480] =-10–j15; X[256]=30 + jβ; and all other values are zero. a. Determine the values of α and β. b. Determine the values of k1, k2 and k3. c. Determine the energy of the signal x[n].
(1 point) Given the following differential equation (x2+2y2)dxdy=1xy, (a) The coefficient functions are M(x,y)= and N(x,y)=...
(1 point) Given the following differential equation (x2+2y2)dxdy=1xy, (a) The coefficient functions are M(x,y)= and N(x,y)= (Please input values for both boxes.) (b) The separable equation, using a substitution of y=ux, is dx+ du=0 (Separate the variables with x with dx only and u with du only.) (Please input values for both boxes.) (c) The solution, given that y(1)=3, is x= Note: You can earn partial credit on this problem. I just need part C. thank you
Calculate the Y values corresponding to the X values given below. Find the critical values for...
Calculate the Y values corresponding to the X values given below. Find the critical values for X for the given polynomial by finding the X values among those given where the first derivative, dy/dx = 0 and/or X values where the second derivative, d­2y/dx2 = 0.    Be sure to find the sign (+ or -) of dy/dx and of d2y/dx2 at all X values. Reference Lesson 13 and the text Appendix A (pp 694 – 698), as needed. Using the...
Please answer the following C question: Read the following files called array-utils5A.c and array-utils5A.h. Build an...
Please answer the following C question: Read the following files called array-utils5A.c and array-utils5A.h. Build an executable with gcc -Wall -DUNIT_TESTS=1 array-utils5A.c The definitions for is_reverse_sorted and all_different are both defective. Rewrite the definitions so that they are correct. The definition for is_alternating is missing. Write a correct definition for that function, and add unit tests for it, using the unit tests for is_reverse_sorted and all_different as models. Please explain the logic errors present in in the definition of is_reverse_sorted...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT