Ira Banks
// CS 171-02
//10/29/2010
// This program will to simulate the following activity. He has 25 chips numbered 1 through 25 in a bag.
// He thinks of a number from 1 to 25. Then he draws numbers from the bag, recording each and returning it to the bag,
//until he draws the number he thought of on two consecutive draws. How many numbers are drawn before the number thought of is drawn on two consecutive draws?
//Print the list of numbers in the order drawn. How many numbers were drawn before the number thought of is drawn the first time? Sort the list
//of numbers drawn and print the list again.

#include <iostream>
#include <string>
#include <array>
#include <cstring>
#include <cstdlib>
using namespace std;



int main()
{
    int number;
    int bag[25];
    
    bag[25] = 1 + 1;
    
    cout << "Please enter the number you are thinking of"/n;
    cin >> number;

And...? What's the question? Line 15 is a seg fault, line 17 has the quotes in the wrong spot and the slash backwards, and everything stops after line 18. I assume there's more?

I have to simulate the program description above and im stuck

#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;



int main()
{
    int number;
    int bag[25];
    int number_drawn;
    int number_drawn1;
    int loop = 0;
    
    bag[25] = 0;
    
    cout << "Please enter the number you are thinking of/n";
    cin >> number;
    
    cout << "Draw two number";
    cin >> number_drawn >> number_drawn1;
    
    for(int loop; loop <= number; loop++)
    {
            cout << number_drawn << number_drawn1;
            }
    
    for(int cntr = 0; cntr < bag[25]; cntr++)
  {
    if(number_drawn == number)
    {
                    cout << " Congrats, you have chosen the right number";
                    }else
                    {
                         cout << "Sorry try agian";
                         }
                         
                         system("pause");
                         return 0;
}}
Be a part of the DaniWeb community

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