do while loop is skipping

Hi all my do while loop is skipping one of my questions that i'm trying to ask.
It is skipping the manx cat tail question, the only other prob is that it is not
assigning a value to the restart variable so it's not recognisin it on the end of my do loop, any help would be great because I just can't seem to figure this out!


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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#include <iostream.h>
#include <windows.h>
#include <string.h>



int main()

{
    int count;
    char guess[30];
    char name[30];
    char password[30]= "Meow!";
    int counter;
    
    char restart;              // variable for restart of test
    int answer1int;   
    int answer2int;            
    char answer1chararray[30]; 
    char answer1chararray_answer[30]= "Tails";
    char answer2chararray[30]; 
    char answer2chararray_answer[30]="Venus";
    char answer1char;
    char answer2char;    
    int correct = 0;
    int incorrect = 0;
        
     for(count=10; count >= 1; count--)
  {
    
      cout << count << endl;
      Sleep(5);
  }
  
  
  
  cout<<"Please Enter Your Name: "<<endl;
  cin.getline(name,30);
  
  cout<<"Now Please Enter The Password"<<endl;
  cin.getline(guess,30);
  
  if((!strcmp (guess, password)))
  {
              cout<<"Gratz...";
              
  }
              
              else
              {
                  // Compares 2 character arrays as long as they end in null \0 which char strings do, only returns boolean value.
                  while ((strcmp (guess, password) != 0) ) //hence why not equal is there, == does not work apparently.

                  {cout<<"Please Enter The Correct Password"<<endl;
                   cin>>guess;}
                  
                  
              }
  
  cout<<"Congratulations you guessed the password correctly!";
  Sleep(500);
  
  system("CLS");
  
  cout<<"Hello and welcome to Credit Crunch Millionaire!!"<<endl;
  cout<<"Please read the questions carefully and when prompted for an answer please";
  cout<<" enter a number from 1-4 corresponding with which answer you choose, this is for the first two questions ONLY."<<endl; 
  cout<<"For questions 3-4 please write the answer out."<<endl;
  cout<<"Finally for questions 5-6 please answer with A-D."<<endl;
  
  Sleep(650);
  system("CLS");
  
  
  
  do{
  cout<<"What is the vitamin name for absorbic acid?"<<endl;
  cout<<"1) Vitamin A "<<endl;
  cout<<"2) Vitamin B "<<endl;
  cout<<"3) Vitamin C "<<endl;                                    //right answer
  cout<<"4) Vitamin D "<<endl;
  cin>>answer1int;
  system("CLS");
  
  cout<<"Who is the current president of Nicaragua?"<<endl;
  cout<<"1)Daniel Ortega"<<endl;                                  //right answer
  cout<<"2) Violeta Chamorro"<<endl;
  cout<<"3)Adolfo Diaz"<<endl;
  cout<<"4)Orlando Montenegro"<<endl;
  cin>>answer2int;
  system("CLS");
  
  
  
  cout<<" NB. Type out the answer and start with a capital letter -Manx cats are famous for not having... "<<endl;
  cin.getline(answer1chararray,30); //Tails
  system("CLS");
  

  
  cout<<" NB. Type out the answer and start with a capital letter.- Who is the greek goddess of love? "<<endl;     
  cin.getline(answer2chararray,30); //venus
  system("CLS");
  
  cout<<" NB. Type in the letter to answer- How many whiskers does the average cat have? "<<endl;
  cout<<"A)6"<<endl;
  cout<<"B)12"<<endl;
  cout<<"C)16"<<endl;
  cout<<"D)24"<<endl; //right answer
  cin>>answer1char;
  system("CLS");
  
  cout<<"NB. Type in the letter to answer- Jehst is bigger than Dr.Dre, is this because he is: "<<endl;
  cout<<" A)Richer"<<endl;
  cout<<" B)Taller"<<endl;
  cout<<" C)Lyrically better"<<endl;
  cout<<" D)None of the above he is a nobody."<<endl; // right answer
  cin>>answer2char;
  system("CLS");
  
  if (answer1int == 3)
  {correct++;}
  else
  {incorrect++;}
  
  if (answer2int == 1)
  {correct++;}
  else
  {incorrect++;}
  
  if ((!strcmp(answer1chararray,answer1chararray_answer)))
  {correct++;}
  else{incorrect++;}
  
  if ((!strcmp(answer2chararray,answer2chararray_answer)))
  {correct++;}
  else
  {incorrect++;}
  
  if(answer1char == 'D' || 'd')
  {correct++;}
  else 
  {incorrect++;}
  
  if(answer2char == 'D' || 'd')
  {correct++}
  else
  {incorrect++;}
  
  cout<< " You have got: " << correct << " correct and; " << incorrect << " incorrect "<<endl<<endl;
  
  cout<<"Would you like to restart the quiz? Please enter Y/N";
  cin>>restart;
  
}while(restart == 'y' || 'Y');



  
 

 
    system("PAUSE");
    return 0;
    
}

}while(restart == 'y' || 'Y'); should be }while(restart == 'y' || restart == 'Y');
ahhh yeah thanks, was gettin towards the end of the day and I was getting a bit frustrated.


Now to figure out why the program is skipping the "Tails" question
You mean that on line 152?
Try flushing cout before getting input
flushing cout?

Whatcha mean flushing? Hav't covered it yet.


It works if I place it at the beginning of the code but not where it is, so i'm really perplexed.
flush makes cout display the last inserted characters, see
http://www.cplusplus.com/reference/iostream/ostream/flush/
http://www.cplusplus.com/reference/iostream/manipulators/flush/

( endl already flushes )
cheers mate will have a look, appreciate the help.
if endl; ahh right I slightly learned in passing about flushing the output buffer <<endl; does and \n doesn't right? Then i've already flushed at the end of it and before, I always use <<endl; at the end of cout if I want a new line.
Yes, but you don't have endl on the last line so you should flush it. endl adds a \n and flushes
Just try calling flush after line 152 and before line 153 to see if this solves the problem
Oh yeah all that works after you corrected me the first time, it's line 95 thats skipping, i'm sure I can see it coming up but skipping v.fast.
Is it skipping the question to be displayed or the input being read?
got it sorted by adding another cin.getline underneath it =)
Topic archived. No new replies allowed.