ok well here is my problem. my code is doing the exact opposite i want it to do. it is saying when a person enters a 1 or anything else other than a 0 it will show up as a the person rolled but i would like it to show up when a person enters a number or letter thats NOT 1 it will show up as
Code://adds the iostream library to the program #include <iostream> #include <cstdlib> #include <stdio.h> #include <stdlib.h> #include <time.h> #define BOOL_H #undef true #undef false //informs the compiler you are using the standard library set using namespace std; const int LOW = 1; const int HIGH = 6; int firstDie; int secondDie; int Choice; int yes; int no; /* Variables to hold random values for the first and the second die on each roll. */ int main () { time_t seconds; time(&seconds); srand((unsigned int) seconds); for ( ;; ) { cout << "Round 1 \n"; cout << "Would you like to roll this round? [1 for yes, 0 for no]:\n\n"; if ( cin >> yes || no == 0 ) {} else {firstDie = rand() % (HIGH - LOW + 1) + LOW; (secondDie = rand() % (HIGH - LOW) + 1) + LOW; cout << "you rolled a "<< firstDie << " and a " << secondDie << endl; break;} } system("pause\n\n\n"); return 0; }



LinkBack URL
About LinkBacks



Want to add some