Middle three digits: Difference between revisions

→‎C: Add output, remove superfluous initialization
(→‎{{header|C}}: Output?)
(→‎C: Add output, remove superfluous initialization)
Line 74:
 
=={{header|C}}==
{{output?|C}}
<lang C>#include <stdio.h>
 
Line 83 ⟶ 82:
int mid3(int num, char *buf)
{
int i = 2, mag = 1;
int tmp = num = num < 0 ? -num : num; /* Discard sign. */
 
Line 122 ⟶ 121:
return 0;
}</lang>
{{out}}
<pre>123: 123
12345: 234
1234567: 345
987654321: 654
10001: 000
-10001: 000
-123: 123
-100: 100
100: 100
-12345: 234
1: too small
2: too small
-1: too small
-10: too small
2002: even length
-2002: even length
0: too small</pre>
 
=={{header|C++}}==