 <ol> <li><p>This is <code>C</code> not <code>C++</code> (eventhough C++ brings enough <code>C</code> compatibility to make that code valid using a conforming C++ compiler with <code>#include &lt;stdio.h&gt;</code>).</p></li> <li><p>The specifier <code>%c</code> is for characters. You're reading and writing <code>int</code>. </p></li> </ol> <p>Thus, you should use <code>%i</code>.</p> <pre><code>int a; int b; printf("a"); scanf("%i", &amp;a); printf("b"); scanf("%i", &amp;b); a=a+b; printf("%i", a); </code></pre> <p>Output</p> <pre><code>a5 b7 12 </code></pre>