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

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)
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...
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.
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
C++ How do you make a 2d array with a user input. For example, the row...
C++ How do you make a 2d array with a user input. For example, the row and columns of the 2d array will be the same so the program can create a square matrix.
Complete the given C++ program (prob1.cpp) to read an array of integers, print the array, and...
Complete the given C++ program (prob1.cpp) to read an array of integers, print the array, and then find the index of the largest element in the array. You are to write two functions, printArray() and getIndexLargest(), which are called from the main function. printArray() outputs integers to std::cout with a space in between numbers and a newline at the end. getIndexLargest () returns the index of the largest element in the array. Recall that indexes start at 0. If there...
Create a C++ program that makes use of both concepts i.e. Array of structure and array...
Create a C++ program that makes use of both concepts i.e. Array of structure and array within the structure by using the following guidelines: 1. Create an Array of 5 Structures of Student Records 2. Each structure must contain: a. An array of Full Name of Student b. Registration Number in proper Format i.e 18-SE-24 c. An array of Marks of 3 subjects d. Display that information of all students in Ascending order using “Name” e. Search a particular student...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT