default:
cout << " Unknown month";
}
break; //break from inner switch
season = letter2;
return season;
case 'M':
case 'm':
cout<< " Enter second and third letters ";
cin>> letter2 >> letter3;
switch (letter2) {
case 'A':
case 'a':
switch (letter3) {
case 'R':
case 'r':
cout << " 03 " << endl;
break;
case 'Y':
case 'y':
cout << " 05 " << endl;
break;
season = letter3;
return season;
Both letter and season are of type char, and only letter is given a value before the condition is evaluated. Ad you are not manually assigning season a value it might always be "less than" letter. However, you shouldn't really do conditions like that anyway.
To show this further if you assign season the value of 'b' and then input the letter 'a' when prompted, as the ascii value of a is smaller than that of the vlaue of 'b', you will enter your while loop.
Also, the variables you created in main are pointless and you should change your function to not take any arguements, they are not needed.
I rewote the code and it is not shutting down, but it is still an indifinite loop. I thinl my test conditions are incorrect. Not sure where ot go next.
#include<iostream>
You're doing it again. You create a variable withouth initializing it and then pass it as a n argument to the function, that doesn't even use that variable. I think you need to ree-read the tutorial on functions.
Also, never do:
1 2
char Q;
char season= Q;
'Q' has no value so you're assigning to 'season' a garbage value. Also, if you then give 'Q' a value, it will not be given to 'season'.
Sorry but theres nothing more that I can say without wasting both our times, go to here: http://www.cplusplus.com/doc/tutorial/functions/ ... and read this tutorial then come back to your code (although its probably better to start from scratch). i'm sure you will be able to figure it out. Feel free to ask anything once you've done that.