
{"id":19017,"date":"2022-07-24T22:40:34","date_gmt":"2022-07-24T17:10:34","guid":{"rendered":"https:\/\/beautifulworknew.wordpress.com\/?p=19017"},"modified":"2022-07-24T22:40:34","modified_gmt":"2022-07-24T17:10:34","slug":"linux-spt-sum-of-numbers","status":"publish","type":"post","link":"https:\/\/www.trueangle.org\/index.php\/2022\/07\/24\/linux-spt-sum-of-numbers\/","title":{"rendered":"Sum of numbers"},"content":{"rendered":"\n<p><\/p>\n\n\n<p>$ls<br>first-example first-example.c new-sum.c sum.c<br>$gcc sum.c -o sum<br>$cat sum.c <br>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>void printhelp(char progname[]);<\/p>\n<p>int main(int argc, char *argv[])<br>{<br>int i;<br>int sum = 0;<\/p>\n<p>\/* Simple sanity check *\/<br>if (argc == 1)<br>{<br>printhelp(argv[0]);<br>return 1;<br>}<\/p>\n<p>for (i=1; i&lt;argc; i++)<br>{<br>sum = sum + atoi(argv[i]);<br>}<br>printf(&#8220;Total sum: %i\\n&#8221;, sum);<br>return 0;<br>}<\/p>\n<p>void printhelp(char progname[])<br>{<br>printf(&#8220;%s integer &#8230;\\n&#8221;, progname);<br>printf(&#8220;This program takes any number of &#8221; <br>&#8220;integer values and sums them up\\n&#8221;);<br>}<br>$.\/sum 1 2 3 <br>Total sum: 6<br>$<\/p>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>$lsfirst-example first-example.c new-sum.c sum.c$gcc sum.c -o sum$cat sum.c #include &lt;stdio.h&gt;#include &lt;stdlib.h&gt;void printhelp(char progname[]); int main(int argc, char *argv[]){int i;int sum = 0; \/* Simple sanity check *\/if (argc == 1){printhelp(argv[0]);return 1;} for (i=1; i&lt;argc; i++){sum = sum + atoi(argv[i]);}printf(&#8220;Total sum: %i\\n&#8221;, sum);return 0;} void printhelp(char progname[]){printf(&#8220;%s integer &#8230;\\n&#8221;, progname);printf(&#8220;This program takes any number of &#8221; &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.trueangle.org\/index.php\/2022\/07\/24\/linux-spt-sum-of-numbers\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Sum of numbers&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/19017"}],"collection":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/comments?post=19017"}],"version-history":[{"count":0,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/posts\/19017\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/media?parent=19017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/categories?post=19017"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.trueangle.org\/index.php\/wp-json\/wp\/v2\/tags?post=19017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}