While loop

  • MHB
  • Thread starter ineedhelpnow
  • Start date
  • Tags
    Loop
  • #1
656
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.
 

Answers and Replies

  • #2
You are checking the wrong variable...it is [m]keepGoing[/m] that stores the user input...:D
 

Suggested for: While loop

Replies
2
Views
527
Replies
8
Views
476
Replies
4
Views
650
Replies
11
Views
1K
Replies
8
Views
1K
Replies
2
Views
939
Back
Top