{"id":24896,"date":"2017-09-06T00:03:29","date_gmt":"2017-09-05T18:33:29","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=24896"},"modified":"2017-09-06T00:03:29","modified_gmt":"2017-09-05T18:33:29","slug":"c-program-perform-addition-subtraction-multiplication-division","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/c-program-perform-addition-subtraction-multiplication-division\/","title":{"rendered":"C program to perform addition, subtraction, multiplication and division"},"content":{"rendered":"<p>C program to perform basic arithmetic operations which are addition, subtraction, multiplication and division of two numbers. Numbers are assumed to be integers and will be entered by the user.<\/p>\n<p>&nbsp;<\/p>\n[ad type=&#8221;banner&#8221;]\n<h2 id=\"c-programming-code\">C programming code<\/h2>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-c code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-c code-embed-code\">#include &lt;stdio.h&gt;<br\/> <br\/>int main()<br\/>{<br\/>   int first, second, add, subtract, multiply;<br\/>   float divide;<br\/> <br\/>   printf(&quot;Enter two integers\\n&quot;);<br\/>   scanf(&quot;%d%d&quot;, &amp;first, &amp;second);<br\/> <br\/>   add = first + second;<br\/>   subtract = first - second;<br\/>   multiply = first * second;<br\/>   divide = first \/ (float)second;   \/\/typecasting<br\/> <br\/>   printf(&quot;Sum = %d\\n&quot;,add);<br\/>   printf(&quot;Difference = %d\\n&quot;,subtract);<br\/>   printf(&quot;Multiplication = %d\\n&quot;,multiply);<br\/>   printf(&quot;Division = %.2f\\n&quot;,divide);<br\/> <br\/>   return 0;<br\/>}<\/code><\/pre> <\/div>\n<p>&nbsp;<\/p>\n[ad type=&#8221;banner&#8221;]\n<p>Download <a title=\"Executable file of arithmetic program\" href=\"http:\/\/www.programmingsimplified.com\/executable\/c\/arithmetic-operations.exe\" target=\"_blank\" rel=\"noopener\">Arithmetic operations<\/a> program.<\/p>\n<p>&nbsp;<\/p>\n[ad type=&#8221;banner&#8221;]\n<p>Output of program:<\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-24898 size-full\" src=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2017\/05\/arithmetic-operations-c.png\" alt=\"\" width=\"469\" height=\"199\" srcset=\"https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2017\/05\/arithmetic-operations-c.png 469w, https:\/\/www.wikitechy.com\/technology\/wp-content\/uploads\/2017\/05\/arithmetic-operations-c-300x127.png 300w\" sizes=\"(max-width: 469px) 100vw, 469px\" \/><\/p>\n<p>&nbsp;<\/p>\n[ad type=&#8221;banner&#8221;]\n<p>In c language when we divide two integers we get integer result for example 5\/2 evaluates to 2. As a general rule integer\/integer = integer and float\/integer = float or integer\/float = float. So we convert denominator to float in our program, you may also write float in numerator. This explicit conversion is known as typecasting.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C program to perform basic arithmetic operations which are addition, subtraction, multiplication and division of two numbers. Numbers are assumed to be integers and will be entered by the user. &nbsp; [ad type=&#8221;banner&#8221;] C programming code &nbsp; [ad type=&#8221;banner&#8221;] Download Arithmetic operations program. &nbsp; [ad type=&#8221;banner&#8221;] Output of program: &nbsp; [ad type=&#8221;banner&#8221;] In c language [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[878,1],"tags":[],"class_list":["post-24896","post","type-post","status-publish","format-standard","hentry","category-c-sharp","category-coding"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/24896","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=24896"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/24896\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=24896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=24896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=24896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}