Question

This assignment is about array operations. You need to count a specific items in an array. Steps to follow are here: • Create
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:-

CODE:-


#include <iostream>

using namespace std;
int getRandomNumber(int min, int max) {               //function to generate random number.
        return (rand() %
           (max- min + 1)) + min;
   }
int main()
{int a[1000],i;
   for(i=0;i<1000;i++)                         //generating 1000 random numbers
   a[i]=getRandomNumber(-100,100);
   int number;
   cout<<"Enter a number : ";
   cin>>number;
   int freq;
   while(number<=100 && number>=-100)                 //calculating frequency of number
   { freq=0;
        for( i=0;i<1000;i++)
        {if(number==a[i])
         freq++;
          
        }
        cout<<"frequency of "<<number<<": "<<freq<<endl;
        cout<<"Enter a number : ";
   cin>>number;
   }
  
  
    return 0;
}


   


CODE OUTPUT:-

1 2 #include <iostream> 3 4 using namespace std; 5. int getRandomNumber(int min, int max) { 6 return (rand() % 7 (max- min +

NOTE:- The above code is in c++.

Add a comment
Know the answer?
Add Answer to:
This assignment is about array operations. You need to count a specific items in an array....
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
  • write c++ program This assignment is about array operations. You need to count a specific items...

    write c++ program This assignment is about array operations. You need to count a specific items in an array. Steps to follow are here: . Create an array with 1000 items and fill it with random numbers from the range of -100, 100 (including -100 and 100). In your program asks user to enter a number, K. Search this number and print the frequency (how many) of this K is found in the array. • Ask another number, and so...

  • code must be c++ thank you This assignment is about array operations. You need to count...

    code must be c++ thank you This assignment is about array operations. You need to count a specific items in an array. Steps to follow are here: • Create an array with 1000 items and fill it with random numbers from the range of -100, 100 (including - 100 and 100). . In your program asks user to enter a number, K. • Search this number and print the frequency (how many) of this K is found in the array...

  • In C++ 1. Write a program that allows a user to enter 10 integer values from...

    In C++ 1. Write a program that allows a user to enter 10 integer values from the keyboard. The values should be stored in an array. 2. The program should then ask the user for a number to search for in the array: The program should use a binary search to determine if the number exists in a list of values that are stored in an array (from Step #1). If the user enters a number that is in the...

  • Write in C# Programming Language.   - count =0; - Create a 2d array "items". string[,] items...

    Write in C# Programming Language.   - count =0; - Create a 2d array "items". string[,] items = new string[100, 4]; - Create a do while loop, when user enter "0", stop the loop. - User enter item name, price, quantity, save these info and subtotal to array. - increase "count++" -conver price(decimal, Convert.ToDecimal() ) and quantity(int) to do mulplication for subtotal - create a for loop (with count ) to cycle through the "items", display item name, price, quantity, and...

  • The purpose of this assignment is to get experience with an array, do while loop and...

    The purpose of this assignment is to get experience with an array, do while loop and read and write file operations. Your goal is to create a program that reads the exam.txt file with 10 scores. After that, the user can select from a 4 choice menu that handles the user’s choices as described in the details below. The program should display the menu until the user selects the menu option quit. The project requirements: It is an important part...

  • ASSIGNMENT: Create a program to do the following: BONUS: A bonus of 20 points if you create the p...

    ASSIGNMENT: Create a program to do the following: BONUS: A bonus of 20 points if you create the program in such a way that there is no limit on the number of names to be handled. 1) Read in names to sort until the user types the “enter” key as the first character of a “C-type” string (the maximum number of names is 20, there is not a maximum length to a name), using a two dimensional array of characters....

  • Write a C++ program that prompts the user with the following menu options: Erase-ArrayContent Count-Words Quit...

    Write a C++ program that prompts the user with the following menu options: Erase-ArrayContent Count-Words Quit 1. For Erase-ArrayContent option, write complete code for the C++ function Erase described below. The prototype for Erase function is as follow: void Erase( int a[ ], int * N, int * Search-Element) The function Erase should remove all occurrences of Search-Element from the array al). Note that array a[ ] is loaded with integer numbers entered by the user through the keyboard. N...

  • Task 1 Main Function: Declare and fill an array with 1000 random integers between 1 -...

    Task 1 Main Function: Declare and fill an array with 1000 random integers between 1 - 1000. You will pass the array into functions that will perform operations on the array. Function 1: Create a function that will output all the integers in the array. (Make sure output is clearly formatted. Function 2: Create a Function that will sum and output all the odd numbers in the array. Function 3: Create a Function that will sum and output all the...

  • My following program has an array which holds 1000 random integers between 1-1000. Now I need...

    My following program has an array which holds 1000 random integers between 1-1000. Now I need help to create an array that holds 10,000 random integer between 1-1000 in my following program. The main goal of this program is time analysis by using bubble sort and binary search algorithms. Please do the following task; 1. Replace the 1000 random integers with 10,000 random integers After change please answer the following question 2. what will be happen, if an array holds...

  • Modify PartTwo.cpp so that it is uses a vector, named vect, instead of an array. PartTwo.cpp...

    Modify PartTwo.cpp so that it is uses a vector, named vect, instead of an array. PartTwo.cpp Is posted here: // This program reads data from a file into an array. Then, it // asks the user for a number. It then compares the user number to // each element in the array, displays the array element if it is larger. // After looking at entire array, it displays the number of elements in the array larger // than the user...

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