Note that there are some explanatory texts on larger screens.

plurals
  1. POwritting a program that inputs a number 1-12 and outputs the corresponding month
    text
    copied!<p>My program is suppose to prompt user to enter a number 1-12 and output the corresponding month. Ok I know I am missing a very important part of this program but right know I am struggling to figure out what to use. Do I need to have a string that includes all the names of the months? Also I know that I need to have something to put after the cout&lt;&lt;"the month is"&lt;&lt; something has to go here so the answer will print but I not sure what right now. I also think I need at have int month= something but not sure if it should be 1-12 or monthname. <strong>Here is my edited program it was working but now it has a debug error the variable "month" is being used without being initialized. What does that mean?</strong></p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; using namespace std; char chr; int main() { int month; cout&lt;&lt;"Enter a number from 1-12."; if (month ==1) cout&lt;&lt;"January"; else if (month==2) cout&lt;&lt; "February"; else if (month==3) cout&lt;&lt;"March"; else if (month==4) cout&lt;&lt;"April"; else if (month==5) cout&lt;&lt;"May"; else if (month==6) cout&lt;&lt;"June"; else if (month==7) cout&lt;&lt;"July"; else if (month==8) cout&lt;&lt;"August"; else if (month==9) cout&lt;&lt;"September"; else if (month==10) cout&lt;&lt;"October"; else if (month==11) cout&lt;&lt;"November"; else if (month==12) cout&lt;&lt;"December"; else if (month&gt;12) cout&lt;&lt;"Sorry I need a number from 1-12."&lt;&lt;endl; else if(month&lt;=12) cout&lt;&lt; "The month is "&lt;&lt;month; cin&gt;&gt;chr; return 0; </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload