Question

Write a C++ program by using array with the size 10. The user will input the...

Write a C++ program by using array with the size 10. The user will input the number between
0 to -10. Then, calculate and display by how many numbers in the array within the range -9 to -2.

1 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>

using namespace std;

int main() {
    int arr[10];
    cout << "Enter 10 integers: ";
    for (int i = 0; i < 10; ++i) {
        cin >> arr[i];
    }
    int count = 0;
    for (int i = 0; i < 10; ++i) {
        if (arr[i] >= -9 && arr[i] <= -2) {
            ++count;
        }
    }
    cout << "Numbers in range -9 to -2 is " << count << endl;
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
Write a C++ program by using array with the size 10. The user will input the...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (C programing, Not C++) Write a program in C that asks the user to input 10...

    (C programing, Not C++) Write a program in C that asks the user to input 10 numbers. Store these numbers in an array. Then ask the user to input a single number. Your program should execute a linear search on the array, trying to find that number. If the number exists in the array, have the program print out which position/element the number was found at. If the target number is not in the array, have the program print out...

  • Write a program named ClassifyScores that classifies a series of scores entered by the user into...

    Write a program named ClassifyScores that classifies a series of scores entered by the user into ranges (0-9, 10-19, and so forth). The scores will be numbers between 0 and 100. Design and implement a program to prompt the user to enter each score separately. If the score is within the correct range, then increment the appropriate range If the score entered is greater than 100, display an error message, ignore the incorrect score, and prompt for the user to...

  • Write a program that asks the user to input 10 integers of an array. The program...

    Write a program that asks the user to input 10 integers of an array. The program then inserts a new value at position (or index) given by the user, shifting each element right and dropping off the last element. For example, in the sample input/output below, the program will insert the value 30 at index 3. All the previous numbers of the array starting from position 3 (i.e., 7 1 20 9 23 8 22 will be shifted one position...

  • In java, write a program that gets 10 integer numbers from the user using user input,...

    In java, write a program that gets 10 integer numbers from the user using user input, and then calculates and display the sum of the numbers that have been read.   Program Requirements: Write the program in three versions with three loops. Put all three loops in the main method of your source code. version1:  use a while loop. version2:  use a do-while loop. version 3:  use a for loop. For each version, use a loop to input 10 int numbers from the user...

  • Write a C program Design a program that uses an array to store 10 randomly generated...

    Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...

  • Write a JavaScript program that will do the following: Create an array of size 50. Store randoml...

    Write a JavaScript program that will do the following: Create an array of size 50. Store randomly generated number (between 0 and 10) into this array. Ask users what number they want to search in the array. Make sure user given number is between 0 and 10. Search the user given number in the array: If the program found the number in the array then display all the indexes where the number was found. If the program does not find...

  • Write a program that first reads an integer for the array size, then reads numbers into...

    Write a program that first reads an integer for the array size, then reads numbers into the array, computes their average, and finds out how many numbers are above the average. Make sure to include pointer syntax. Example output: Enter array size: 10 10 random numbers between 1 and 10 generated are: 2 8 5 1 10 5 9 9 3 5 The average is: 5.7 Number of items above the average = 4 C++ Code only.

  • In C plus plus Objective: Create an array of numbers based upon user input. Program logic:...

    In C plus plus Objective: Create an array of numbers based upon user input. Program logic: Ask the user for how big to size the array. Create an array based upon that size. Ask for a number, add that number to the array. Repeat adding to the end until all numbers have been entered or until they enter -1 for the number. Print the list.

  • Write a C++ program that will create an array with a given number of elements. Use...

    Write a C++ program that will create an array with a given number of elements. Use size = 10 for demonstration purposes, but write the program where the size of the array can be changed by changing the value of one constant. Fill the array with random numbers between 0 and 100. Write the program to perform the following operations: 1. Find and display the largest value in the array. 2. Find and display the smallest value in the array....

  • In C++: Write a program that asks the user for an array of X numbers. Your...

    In C++: Write a program that asks the user for an array of X numbers. Your program moves the largest number all the way to the right, and then shows it to the user. Hint: Use a loop to swap X times, but only swap if the number on the left is bigger than the number on the right. Sample Run: How many numbers would you like to enter? 6 Please enter number 1: 10 Please enter number 2: 8...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT