consecutive coin flip ISSUE

HERE IS A COPY OF THE PROGRAM







#include
//coin toss average
//spnecer wazlavek

main()

{



int iTemp = ''; //temporary flip value
int iGoal = ''; //consecutive goal
int iCnt = 0; //flip counter
int iFlp = 0; //current consecutive flips


printf("

Please input the consecutive count you would like to acheive:");


scanf("%d", &iGoal); // how many coin flips


do
{

iTemp = (rand() % 2); //heads or tails rep by 0,1

printf("%d
", iTemp); //debug purposes

if (iTemp = 1) //beginning of if
{

iFlp++; //current consecutive flips

}

else

{

iFlp = 0; // reset flip if un-consecutive

}// end of if



iCnt++; //count up 1
iTemp = ''; //reset the coin


printf("consecutive flip atm is %d and count is %d", iFlp, iCnt); //added to print the consecutive flips

}
while (iGoal != iFlp); //end of do-while

printf("

It took %d flips to obtain %d wins in a row", iCnt, iGoal); //reasult
}// end of prog







added plenty of comments to give you a step by step..

The issue that i am having is that the flip counter counts correctly up until the last printf and then it just displays the goal rather than the iCnt integer.


please please help :) much appreciated

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories