{"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>\u00a0<\/p>\n[ad type=\u201dbanner\u201d]\n<h2 id=\"c-programming-code\">C programming code<\/h2>\n[pastacode lang=\u201dc\u201d manual=\u201d%23include%20%3Cstdio.h%3E%0A%20%0Aint%20main()%0A%7B%0A%20%20%20int%20first%2C%20second%2C%20add%2C%20subtract%2C%20multiply%3B%0A%20%20%20float%20divide%3B%0A%20%0A%20%20%20printf(%22Enter%20two%20integers%5Cn%22)%3B%0A%20%20%20scanf(%22%25d%25d%22%2C%20%26first%2C%20%26second)%3B%0A%20%0A%20%20%20add%20%3D%20first%20%2B%20second%3B%0A%20%20%20subtract%20%3D%20first%20-%20second%3B%0A%20%20%20multiply%20%3D%20first%20*%20second%3B%0A%20%20%20divide%20%3D%20first%20%2F%20(float)second%3B%20%20%20%2F%2Ftypecasting%0A%20%0A%20%20%20printf(%22Sum%20%3D%20%25d%5Cn%22%2Cadd)%3B%0A%20%20%20printf(%22Difference%20%3D%20%25d%5Cn%22%2Csubtract)%3B%0A%20%20%20printf(%22Multiplication%20%3D%20%25d%5Cn%22%2Cmultiply)%3B%0A%20%20%20printf(%22Division%20%3D%20%25.2f%5Cn%22%2Cdivide)%3B%0A%20%0A%20%20%20return%200%3B%0A%7D\u201d message=\u201d\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<p>\u00a0<\/p>\n[ad type=\u201dbanner\u201d]\n<p>Download <a title=\"Executable file of arithmetic program\" href=\"http:\/\/www.programmingsimplified.com\/executable\/c\/arithmetic-operations.exe\">Arithmetic operations<\/a> program.<\/p>\n<p>\u00a0<\/p>\n[ad type=\u201dbanner\u201d]\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>\u00a0<\/p>\n[ad type=\u201dbanner\u201d]\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. \u00a0 [ad type=\u201dbanner\u201d] C programming code [pastacode lang=\u201dc\u201d manual=\u201d%23include%20%3Cstdio.h%3E%0A%20%0Aint%20main()%0A%7B%0A%20%20%20int%20first%2C%20second%2C%20add%2C%20subtract%2C%20multiply%3B%0A%20%20%20float%20divide%3B%0A%20%0A%20%20%20printf(%22Enter%20two%20integers%5Cn%22)%3B%0A%20%20%20scanf(%22%25d%25d%22%2C%20%26first%2C%20%26second)%3B%0A%20%0A%20%20%20add%20%3D%20first%20%2B%20second%3B%0A%20%20%20subtract%20%3D%20first%20-%20second%3B%0A%20%20%20multiply%20%3D%20first%20*%20second%3B%0A%20%20%20divide%20%3D%20first%20%2F%20(float)second%3B%20%20%20%2F%2Ftypecasting%0A%20%0A%20%20%20printf(%22Sum%20%3D%20%25d%5Cn%22%2Cadd)%3B%0A%20%20%20printf(%22Difference%20%3D%20%25d%5Cn%22%2Csubtract)%3B%0A%20%20%20printf(%22Multiplication%20%3D%20%25d%5Cn%22%2Cmultiply)%3B%0A%20%20%20printf(%22Division%20%3D%20%25.2f%5Cn%22%2Cdivide)%3B%0A%20%0A%20%20%20return%200%3B%0A%7D\u201d message=\u201d\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/] \u00a0 [ad type=\u201dbanner\u201d] Download Arithmetic operations program. \u00a0 [ad type=\u201dbanner\u201d] Output of program: [&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}]}}