Sentinel

hi,

can anyone guide me how to make my sentiel code work. Tks

Last edited on
@j2013: What is the error you are seeing?

Some things which are not clear in your code:
Do you expect to break the while loop using your input? In that case, you should use while (toupper(alphabet) != 'E')

What is sentinel character used for?
but it dun work
I think the problem might be no brackets around inner loop the compiler won't call that a problem but do you want
 
cout << endl;

Included in the loop try using
[code] and ['/code] around code no '
Cause I'm confused
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
using namespace std;
int main()
{
     char alphabet = 'D';
     int count;
     char sentinel = 'X';
     while (toupper(sentinel) != 'E')
     {
          cout << "Please enter an alphabet: ";
          cin >> alphabet;
          switch (alphabet)
          {
               case 'T' : count = 3;
               break;
               case 'S' : count = 6;
               break;
               case 'N': count = 9;
               break;
               default: count = 12;
          }
          for (int i = 0; i < count; i++) // outer loop
          {
               cout << alphabet ;
           }
     }
}//main 

Why do you need the inner loop
Also make instructions more clear...
Why do you have alphabet initialized at the beginning??
What does sentinal do? Why not just have
While(1)
Sentinel is never used besides that
Last edited on
I didn't understand before ok make alphabet an array
Then not inside the while loop
Make a for loop to loop through the chars
Topic archived. No new replies allowed.