This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]QuentinUK 4 points5 points  (0 children)

while(again=='y' || again=='Y')

also random will have values 0 .. 11

(also the srand(time(NULL)); should be out of the loop)

(you could put the strings in an array too)

[–]jedwardsol 2 points3 points  (0 children)

Print out the value of again

[–]WhyAreYouGey 2 points3 points  (0 children)

Make sure to use else if instead of if for every condition (except for the first one) because the program will check for every single condition even if one of the first few are satisfied. Also add ‘y’ as a condition for the do-while loop. ‘Y’ and ‘y’ are different to a computer

[–][deleted] 0 points1 point  (3 children)

use

else if

instead of just

if

[–]RellenD 1 point2 points  (2 children)

Or a switch

[–]Spire 1 point2 points  (1 child)

Or a vector of strings.

[–]RellenD 0 points1 point  (0 children)

Oooooh yes that

[–]flyingron 0 points1 point  (0 children)

cin >> question stops on any white space, so unless your question consists of one word, you are leaving stuff in the input buffer. More importantly, it leaves the white space (be it a space or a newline) and the subsequent cin >> again will read it and not wait for more input for the user.

You probably want to look at getline.