Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are some things unclear with your code and explanation. I will try to clarify and explain as well as possible.</p> <p>First of all, the program works fine when I ran it. There were some aesthetic problems, but we will ignore that for now.</p> <p>So, you have grasped the basics of I/O. When you use <strong>cout</strong>, it outputs something, and when you use <strong>cin</strong>, it is an input operator. Therefore, you must <strong>input</strong> something for it to work, as shown in example below:</p> <pre><code>//Code int x; cout &lt;&lt;"Enter an integer: "&lt;&lt;; cin &gt;&gt; xxx; </code></pre> <p>What should appear on console:</p> <pre><code>&gt;Enter an integer: _ </code></pre> <p>(Underscore is cursor). You then should enter an integer</p> <pre><code>&gt;Enter an integer: 231 </code></pre> <p>Then, upon pressing enter, the integer you entered, 231, is stored in XXX. Here I have to pause and ask, what is the reason for the "2011" in your code:</p> <pre><code>cout &lt;&lt; "Enter an integer: 2011 "; </code></pre> <p>If you think that's the input, it isn't. You have to manually write something in the console window after you run it. If it is something else, it is distracting and...well...useless.</p> <p>The same principles apply to the <strong>string</strong> component. If you need me to clarify, just let me know. </p> <p>Also, you really should use spaces to clear up your outputs. Your output text is displayed according to:</p> <pre><code>cout &lt;&lt; yyy &lt;&lt; "entered" &lt;&lt;&lt; xxx; </code></pre> <p>Instead, you should use:</p> <pre><code>cout &lt;&lt; yyy &lt;&lt; " entered " &lt;&lt; xxx; </code></pre> <p>This gives a neater output that you can read, i.e.</p> <pre><code>&gt;Johnentered231 </code></pre> <p>versus</p> <pre><code>&gt;John entered 231 </code></pre> <p><strong>Based on your comment</strong></p> <p>Here are some links to get you started:</p> <p><em>Language:</em> <a href="http://www.cplusplus.com/doc/tutorial/" rel="nofollow">C++ Tutorial (follow them sequentially!)</a></p> <p><em>Compiler</em>: <a href="http://www.bloodshed.net/devcpp.html" rel="nofollow">BloodShed Dev</a> <a href="http://msdn.microsoft.com/en-us/vstudio/aa718325.aspx" rel="nofollow">Visual Studio (C++ and more)</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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