Question

In: Computer Science

how to make a program in c++ that has an array that holds up to 25...

how to make a program in c++ that has an array that holds up to 25 digits.Then have a user input 25 values and check to see if each input value is between 10 and 50?

Solutions

Expert Solution

#include<iostream>
using namespace std;
int main(){
   int numbers[25];
   cout<<"Enter the 25 numbers";
   for(int i=0;i<25;i++)
       cin>>numbers[i];
   cout<<"\nChecking whether the entered numbers are between 10 and 50 : \n";
   for(int i=0;i<25;i++){
       if(numbers[i] > 10 && numbers[i]<50)
           cout<<"The number "<<i+1<<" is "<<numbers[i]<<" which is between 10 and 50\n";
       else
           cout<<"The number "<<i+1<<" is "<<numbers[i]<<" which is not between 10 and 50\n";
   }
   return 0;
}

====================================

======================

output

======================

Enter the 25 numbers 3 9 10 11 49 50 51 34 23 45   76 43 12 97 54 33 -8 0 100 90 -67 -16 78 53 78
Checking whether the entered numbers are between 10 and 50 :
The number 1 is 3 which is not between 10 and 50
The number 2 is 9 which is not between 10 and 50
The number 3 is 10 which is not between 10 and 50
The number 4 is 11 which is between 10 and 50
The number 5 is 49 which is between 10 and 50
The number 6 is 50 which is not between 10 and 50
The number 7 is 51 which is not between 10 and 50
The number 8 is 34 which is between 10 and 50
The number 9 is 23 which is between 10 and 50
The number 10 is 45 which is between 10 and 50
The number 11 is 76 which is not between 10 and 50
The number 12 is 43 which is between 10 and 50
The number 13 is 12 which is between 10 and 50
The number 14 is 97 which is not between 10 and 50
The number 15 is 54 which is not between 10 and 50
The number 16 is 33 which is between 10 and 50
The number 17 is -8 which is not between 10 and 50
The number 18 is 0 which is not between 10 and 50
The number 19 is 100 which is not between 10 and 50
The number 20 is 90 which is not between 10 and 50
The number 21 is -67 which is not between 10 and 50
The number 22 is -16 which is not between 10 and 50
The number 23 is 78 which is not between 10 and 50
The number 24 is 53 which is not between 10 and 50
The number 25 is 78 which is not between 10 and 50


Related Solutions

In C++, write a program that will read up to 10 letters (characters) into an array...
In C++, write a program that will read up to 10 letters (characters) into an array and write the letters back to the screen in the reverse order. The program should prompt the user to input all values and can determine whether the input has ended by a punctuation mark such as ‘.’ (make sure that you’ll include meaningful and intuitive messages to the user). For example, if the input is abcde, the output should be edcba. Include appropriate messaging...
C++ Write a program to declare an array of double of size 25, ask the user...
C++ Write a program to declare an array of double of size 25, ask the user to input all array elements from the keyboard, then write a function named out_of_order that will test this array for the condition a[0] >= a[1] >= a[2] >= ... > a[24] The function returns a -1 if the elements are not out of order, otherwise it returns the index of the first element that is out of order. Explain what you do to avoid...
Write a program in c++ to do the following: 2. Create an array to hold up...
Write a program in c++ to do the following: 2. Create an array to hold up to 20 integers. 3. Create a data file or download attached text file (twenty_numbers.txt) that contains UP TO 20 integers. 4. Request the input and output file names from the user. Open the files being sure to check the file state. 5. Request from the user HOW MANY numbers to read from the data file, up to twenty. Request the number until the user...
Program in C: Write a program in C that reorders the elements in an array in...
Program in C: Write a program in C that reorders the elements in an array in ascending order from least to greatest. The array is {1,4,3,2,6,5,9,8,7,10}. You must use a swap function and a main function in the code. (Hint: Use void swap and swap)
How to make a 2D array Tic Tac Toe game in C?
How to make a 2D array Tic Tac Toe game in C?
How to make an array without setting size?c++ cant figure this out without wanting to make...
How to make an array without setting size?c++ cant figure this out without wanting to make a vector or set a fixed size to the numbers. Prompt the user to ask how many numbers you wish to read. Then based on that fill out the elements of one dimensional array with integer numbers. Then sort the numbers and print the original and sorted numbers in ascending order side by side.
C++ PLEASE---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- In this program, you will analyze an array
C++ PLEASE---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- In this program, you will analyze an array of 10 characters storing a gene sequence. You will be given a subsequence of 3 characters to look for within this array. If the subsequence is found, print the message: Subsequence <XXX> found at index <i>. Where i is the starting index of the subsequence in the array. Otherwise, print Subsequence <XXX> not found. The array of characters and the subsequence will be given through standard input. Read them and...
C++ Program: Write another program (in C++) that will allocate a local static array of integers...
C++ Program: Write another program (in C++) that will allocate a local static array of integers and then a dynamic array of integers. Are they stored next to each other? You can examine this by examining the memory addresses where they are located. As described in class, on some systems the size of a dynamic array is actually stored in the bytes previous to a dynamically allocated array. Through some experiments on your own, try to see if this is...
Write a program in C that declares the following array: int. array[] = { 1, 2,...
Write a program in C that declares the following array: int. array[] = { 1, 2, 4, 8, 16, 32 } Then write some code that accepts a number between 0 and 5 from the user and stores it in a variable called "index". Write some code that retrieves the item specified by the index, like this: int item = array[index]; Then write code that outputs the corresponding array entry based on the number the user entered. Example output: The...
Given the following array, write a program in C++ to sort the array using a selection...
Given the following array, write a program in C++ to sort the array using a selection sort and display the number of scores that are less than 500 and those greater than 500. Scores[0] = 198 Scores[3] = 85 Scores[6] = 73 Scores[9] = 989 Scores[1] = 486 Scores[4] = 216 Scores[7] = 319 Scores[2] = 651 Scores[5] = 912 Scores[8] = 846
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT