Write a program to accomplish the following tasks:

  1. Generate arbitrary number of random integer numbers between [0-100]
  2. Save or load the numbers from/to a text file based on user option
  3. Search the generated list for an arbitrary number entered by a user
  4. Use Linear and Binary search algorithms based on a user option
  5. Computes CPU time used by either search algorithm
  6. Use menu-based interaction with the user


Program Description: Arrays

#include <iostream>
#include <ctime>
#include <cstdlib>
#include <fstream>
#include <string>

using namespace std;

int main()


    int max, random_number, x;
    max= 100;

    for (x=0; x<=1000, x=x+1) {

    srand(time (0));
    random_number = (ran () % max) + 1;

    cout << random_number << endl;


    sytem ("pause")


        string file;
    ifstream fin;
    int SaveNumbers= n1 , n2;



    cout << "enter name of file to connect to: ";
    cin >> file;
    fin.open (file.c str());

    } while(!fin);

    string line = "---------------------------------------n"
    string msg1 = " Please enter two numbers n1 n2"
    string msg2 = " Please select an option from the above menu --> ";

    string menu = " [0,9] Quit n"
                           " [1] Confirm input  n"
                           " [2] Add            n"
                           " [3] Subtract       n"
                           " [4] Multiply       n"
                           " [5] Divide         n"

    cout << msq1;
    cin >> n1 >> n2;
    count << "nn"
    cout << menu1 << "nn" msg 2;
        cin >> op1;
        cout << line;

    for menu1 switch( op1 )


        Case 0:
    case 9: return 0; break
    case 1: cout << n1 << " " << n2 << endl; break;
    case 2: cout << n1 + n2 << endl; break;
    case 3: cout << n1 - n2 << endl; break;
    case 4: cout << n1 * n2 << endl; break;
    case 5: cout << n1 / n2 << endl; break;
        default: cout << "indvalid option...n" break;

    cout << "nn";
    cout << meanu << "nn" << msg2;
    char op2;
    char op2;
        cout << line;

    for menu2 switch ( op2 )
    case 'x' :
    case 'X' :
    case 'q' :
    case 'Q' : return 0; break;
    case '!' :

    case '?' : cout << n1 << " " << n2 << endl; break;
    case '+' : cout << n1 + n2 << endl; break;
    case '-' : cout << n1 - n2 << endl; break;
    case '*' : cout << n1 * n2 << endl; break;
    case '' :
    case '/' : cout << n1 / n2 << endl; break;
    default: cout "invalid option...n"; break;


   return 0;

    bool SaveNumbers( const char* pszFilename, int* piNumbers, int iSize )

        string file;
    ifstream fin;
    int n1, n2;

    fin >> n1;
    fin >> n2;




Posting requests for help must be well thought out if you want help quickly and correctly.  Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful?  Check your post with these checkpoints - what is it [i]you[/i] missed:
[*]Ask a question that can be answered. Do not ask
- What's wrong with my code?
- Why doesn't this work?
- Anything else that does not give us useful information.
[*]Post your code.  If we don't know what you did, how can we possibly help?
- Use [b]PROPER FORMATTING[/b] -- see this
- Use CODE Tags so your formatting is preserved.
If we can't follow your code, it's difficult to help. We don't care that you're still working on it. If you want us to read it, it must be readable
[*]Explain what the code is supposed to do.  If we don't know where the target is, how can we help you hit it?
[*]Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what went wrong and how far from the target you are?
[*]If you have errors, post them! We can't see your screen.  We can't read your mind. You need to tell us what happened.
[*]Do [b]not[/b] ask for code. We are not a coding service. We will help you fix your code. 
    If anyone posts working code for you, they are a cheater. 
    If you use that code [i]you[/i] are a cheater.
[*]Do [b]not[/b] bore us with how new you are. We can tell by your code.
- Do not apologize. We were all new, and unless you are completely 
  brain dead you will get better.
- Do not ask us to "take it easy on you."
- Do not say "I don't know what's going on." That's obvious since
  you posted for help. Use that time wisely by [b]explaining[/b] as best 
  you can so we can help.
[*]Do not apologize for posting 'late'. We don't have any expectations on when you should be posting - 10 minutes or 10 days. We aren't timing your responses.
[*][b]Do not post your requirements and nothing else. [/b]We view that as a lazy do-nothing student that wants us to do their work for them. That's cheating and we [i]will[/i] be hard on you.
[*]Do not attach files except when absolutely necessary. Most of us are not going to download files.  Add the information to your post.
[*][b]Do not tell us how urgent it is.[/b] Seriously, for us there is no urgency at all. Many that can help will ignore any URGENT or ASAP requests.
[*]Create a [b][i]good[/i][/b] title for your post. The title [b]C++[/b] in the C++ forum is bloody redundant and worthless!  [b]What's wrong?[/b] equally so. What are you having trouble with? [i]There[/i] is your title. [i](note: [b]my program[/b] is not the answer.)[/i]
Think more about your next post so we don't have to play 20 questions to get the info we need to help you.


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.