Trying to solve a probability problem in TC++ .... need help ..

Discussion in 'C++' started by crazysunny21, Sep 20, 2007.

  1. crazysunny21

    crazysunny21 New Member

    Joined:
    Sep 20, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hi ..

    my name is Sunny... i am a beginner in C++ lang...

    i m trying to write a program to check the probability of tossing a coin 2,3,4 times or n number of times ....

    now as i said it is tossing of coin .. so there are just 2 possibilities ... either H or T ...

    i wanna have a sample space set ... for tht i have thought something but i dont know whether it is possible or not ...

    i wanna know :

    1. usually we define array with some size .. eg int a[5] which can store 5 elements ... i wanna know is it possible to declare an array whose size is not fixed ....

    2. if i m having 2 arrays of char type ... can i concatinate i th and j th element of these arrays and store the result in 3rd array ... and if yes how .... please if u can tell me the syntax ...

    3. like in java we can count the length of the array by using
    lenght.arrayname ... can we also count the length of array in C++ ...

    these are some of the basic questions as of now in my mind ... if some one can plzzzz help me out ...

    Sunny ....
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,376
    Likes Received:
    388
    Trophy Points:
    83
    You cannot have arrays but you have pointers for that.

    You can use the function strcat

    Nope. You need to know the element length as it cannot be variable in C++
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,376
    Likes Received:
    388
    Trophy Points:
    83
    Moved the thread to C-C++ forum.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice