Continuously Bid with While Loop - Stop at 'n' | Sample Program

  • Context:
  • Thread starter Thread starter ineedhelpnow
  • Start date Start date
  • Tags Tags
    Loop
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 12K views
ineedhelpnow
Messages
649
Reaction score
0
Write an expression that continues to bid until the user enters 'n'.

Sample program:
Code:
#include <iostream>
using namespace std;

int main() {
   char keepGoing = '-';
   int nextBid = 0;

   srand(5);
   while (<STUDENT CODE>) {
      nextBid = nextBid + (rand()%10 + 1);
      cout << "I'll bid $" << nextBid << "!" << endl;
      cout << "Continue bidding? ";
      cin >> keepGoing;
   }
   cout << endl;

   return 0;
}

help me (Headbang) i tried nextBid<'n' nextBid != 'n' !(nextBid='n'). nothing works.
 
Physics news on Phys.org
You are checking the wrong variable...it is [m]keepGoing[/m] that stores the user input...:D