{"id":27248,"date":"2021-11-20T11:03:59","date_gmt":"2021-11-20T07:33:59","guid":{"rendered":"https:\/\/privateblog.maktabkhooneh.org\/mag\/?p=27248"},"modified":"2026-04-06T18:46:06","modified_gmt":"2026-04-06T15:16:06","slug":"how-to-write-calculator-in-c-language","status":"publish","type":"post","link":"https:\/\/maktabkhooneh.org\/mag\/how-to-write-calculator-in-c-language\/","title":{"rendered":"\u0622\u0645\u0648\u0632\u0634 \u0646\u062d\u0648\u0647 \u0646\u0648\u0634\u062a\u0646 \u0628\u0631\u0646\u0627\u0645\u0647 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0628\u0647 \u0632\u0628\u0627\u0646 c"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u06a9\u062f \u0628\u0631\u0646\u0627\u0645\u0647 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0628\u0647 \u0632\u0628\u0627\u0646 c<\/h2>\n\n\n\n<p>\u062f\u0631 \u0627\u06cc\u0646 \u0645\u0642\u0627\u0644\u0647 \u0645\u06cc\u200c\u062e\u0648\u0627\u0647\u06cc\u0645 \u0628\u0647 \u0646\u062d\u0648\u0647 \u0646\u0648\u0634\u062a\u0646 <strong>\u06a9\u062f \u0628\u0631\u0646\u0627\u0645\u0647 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0628\u0647 \u0632\u0628\u0627\u0646 c<\/strong> \u0628\u067e\u0631\u062f\u0627\u0632\u06cc\u0645.<br>\n\u0647\u0645\u0627\u0646\u0637\u0648\u0631 \u06a9\u0647 \u0645\u06cc\u200c\u062f\u0627\u0646\u06cc\u062f \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0646\u0631\u0645\u200c\u0627\u0641\u0632\u0627\u0631 \u0633\u0627\u062f\u0647\u200c\u0627\u06cc \u0627\u0633\u062a \u06a9\u0647 \u0628\u0631\u0627\u06cc \u0627\u0646\u062c\u0627\u0645 \u0639\u0645\u06cc\u0627\u062a\u200c\u0647\u0627\u06cc \u0645\u062e\u062a\u0644\u0641 \u0645\u0627\u0646\u0646\u062f \u062c\u0645\u0639 \u060c \u062a\u0641\u0631\u06cc\u0642 \u060c \u0636\u0631\u0628 \u060c \u062a\u0642\u0633\u06cc\u0645 \u060c<br>\n\u062f\u0631\u0635\u062f \u0648 &#8230; \u0628\u0647 \u06a9\u0627\u0631\u0645\u06cc\u200c\u0631\u0648\u062f. \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628\u200c\u0647\u0627\u06cc \u067e\u06cc\u0686\u06cc\u062f\u0647\u200c\u062a\u0631 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u0646\u062f \u0628\u0631\u0627\u06cc \u0645\u062d\u0627\u0633\u0628\u0627\u062a \u067e\u06cc\u0686\u06cc\u062f\u0647\u200c\u062a\u0631 \u0645\u0627\u0646\u0646\u062f \u062a\u0648\u0627\u0628\u0639 \u0645\u062b\u0644\u062b\u0627\u062a\u06cc \u060c \u062a\u0648\u0627\u0628\u0639 \u0644\u06af\u0627\u0631\u06cc\u062a\u0645 \u06cc\u0627 \u062a\u0648\u0627\u0628\u0639<br>\n\u0647\u0630\u0644\u0648\u0644\u06cc \u0645\u0648\u0631\u062f \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0642\u0631\u0627\u0631 \u06af\u06cc\u0631\u062f.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u0627\u0644\u06af\u0648\u0631\u06cc\u062a\u0645 \u0628\u0631\u0627\u06cc \u0646\u0648\u0634\u062a\u0646 \u06a9\u062f \u0628\u0631\u0646\u0627\u0645\u0647 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0628\u0647 \u0632\u0628\u0627\u0646 \u0633\u06cc<\/h2>\n\n\n\n<p>\u0645\u0631\u0627\u062d\u0644 \u0627\u06cc\u062c\u0627\u062f \u0627\u0644\u06af\u0648\u0631\u06cc\u062a\u0645 \u0628\u0631\u0627\u06cc \u0646\u0648\u0634\u062a\u0646 \u06a9\u062f \u0628\u0631\u0646\u0627\u0645\u0647 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0628\u0647 \u0632\u0628\u0627\u0646 \u0633\u06cc:<\/p>\n\n\n<div class=\"jet-listing-grid--50121\" style=\"\"><div class=\"jet-listing-dynamic-field-block zht-maktab-khooneh-course cb-fb2qc30r\"data-is-block=\"jet-engine\/dynamic-field\"><div class=\"jet-listing-dynamic-field__content\" >\n<div class=\"course-card\">\n    <div class=\"course-card-img\">\n        <img decoding=\"async\" \n            data-src=\"https:\/\/media1.maktabkhooneh.org\/CACHE\/images\/courses\/images\/C-Programming-Language\/59ff307408416a2f9052fc08426b4c76.webp?expire=4893471932&#038;token=18830249278300c283abe260a23ed703&#038;md5=GIMCSSeDAMKDq-Jgoj7XAw==\" \n            alt=\"\u0622\u0645\u0648\u0632\u0634 \u062c\u0627\u0645\u0639 \u0632\u0628\u0627\u0646 \u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc \u0633\u06cc\" \n            title=\"\u0622\u0645\u0648\u0632\u0634 \u062c\u0627\u0645\u0639 \u0632\u0628\u0627\u0646 \u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc \u0633\u06cc\" \n            width=\"100%\" \n            height=\"auto\"\n           \n         src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\">\n    <\/div>\n\n    <div class=\"course-details\">\n        <a href=\"https:\/\/maktabkhooneh.org\/course\/%D8%A2%D9%85%D9%88%D8%B2%D8%B4-%D8%AC%D8%A7%D9%85%D8%B9-%D8%B2%D8%A8%D8%A7%D9%86-%D8%A8%D8%B1%D9%86%D8%A7%D9%85%D9%87-%D9%86%D9%88%DB%8C%D8%B3%DB%8C-%D8%B3%DB%8C-mk5493\/\" class=\"course-title\" target=\"_blank\" rel=\"noopener noreferrer\">\n            \u0622\u0645\u0648\u0632\u0634 \u062c\u0627\u0645\u0639 \u0632\u0628\u0627\u0646 \u0628\u0631\u0646\u0627\u0645\u0647 \u0646\u0648\u06cc\u0633\u06cc \u0633\u06cc        <\/a>\n\n        <div class=\"course-price\">\n            \n                <span class=\"real-price\">\n                                            \u06f7\u06f9\u06f9,\u06f0\u06f0\u06f0                                    <\/span>\n\n                <span>\n                    <span class=\"discounted-price\">\n                        \u06f3\u06f5\u06f9,\u06f5\u06f5\u06f0                    <\/span>\n                    <span class=\"price-currency\">\u062a\u0648\u0645\u0627\u0646<\/span>\n                <\/span>\n\n                                    <div class=\"discount-percentage\">\n                        \u06f5\u06f5%                    <\/div>\n                \n                    <\/div>\n        <button class=\"course-cta-button\" data-course-url=\"https:\/\/maktabkhooneh.org\/course\/%D8%A2%D9%85%D9%88%D8%B2%D8%B4-%D8%AC%D8%A7%D9%85%D8%B9-%D8%B2%D8%A8%D8%A7%D9%86-%D8%A8%D8%B1%D9%86%D8%A7%D9%85%D9%87-%D9%86%D9%88%DB%8C%D8%B3%DB%8C-%D8%B3%DB%8C-mk5493\/\">\n            \u0645\u0634\u0627\u0647\u062f\u0647 \u0648 \u062e\u0631\u06cc\u062f        <\/button>\n    <\/div>\n<\/div>\n<\/div><\/div><\/div>\n\n\n<ol class=\"wp-block-list\">\n<li>\u0642\u062f\u0645 \u0627\u0648\u0644: \u0645\u062a\u063a\u06cc\u0631\u0647\u0627\u06cc n1 \u060c n2 \u0648 &#8230; \u060c res \u0648 opt \u0631\u0627 \u0628\u0631\u0627\u06cc \u0628\u0631\u0646\u0627\u0645\u0647 \u062a\u0639\u0631\u06cc\u0641 \u06a9\u0646\u06cc\u062f. ( \u0628\u0647 \u0637\u0648\u0631\u06cc \u06a9\u0647 \u0628\u0631\u0646\u0627\u0645\u0647 \u0628\u0631\u0627\u06cc \u0645\u062a\u063a\u06cc\u0631\u0647\u0627\u06cc n \u0645\u0642\u0627\u062f\u06cc\u0631 \u0639\u062f\u062f\u06cc<br><br>\u062f\u0631\u06cc\u0627\u0641\u062a \u0645\u06cc\u200c\u06a9\u0646\u062f \u060c \u0645\u062a\u063a\u06cc\u0631 opt \u0628\u0631\u0627\u06cc \u062a\u0639\u0631\u06cc\u0641 \u0646\u0645\u0627\u062f\u0647\u0627\u06cc \u0639\u0645\u0644\u06af\u0631 \u0628\u0647 \u06a9\u0627\u0631 \u0645\u06cc\u200c\u0631\u0648\u062f \u0648 \u0646\u062a\u0627\u06cc\u062c \u062f\u0631\u0645\u062a\u063a\u06cc\u0631 res \u0630\u062e\u06cc\u0631\u0647 \u0645\u06cc\u200c\u0634\u0648\u0646\u062f. )<\/li>\n\n\n\n<li>\u0642\u062f\u0645 \u062f\u0648\u0645: \u0639\u0645\u0644\u06af\u0631 \u0631\u0627 \u0686\u0627\u067e \u06a9\u0646\u062f. ( \u0636\u0631\u0628 \u060c \u062a\u0642\u0633\u06cc\u0645 \u060c \u062c\u0645\u0639 \u06cc\u0627 \u062a\u0641\u0631\u06cc\u0642 )<\/li>\n\n\n\n<li>\u0642\u062f\u0645 \u0633\u0648\u0645: \u0639\u0645\u0644\u06af\u0631 \u0645\u0648\u062f \u0646\u0638\u0631 \u0627\u0646\u062a\u062e\u0627\u0628 \u0634\u0648\u062f.<\/li>\n\n\n\n<li>\u0642\u062f\u0645 \u0686\u0647\u0627\u0631\u0645: \u062f\u0648 \u0639\u062f\u062f \u0631\u0627 \u0628\u0647 \u0639\u0646\u0648\u0627\u0646 \u0648\u0631\u0648\u062f\u06cc n1 \u0648 n2 \u062f\u0631\u06cc\u0627\u0641\u062a \u06a9\u0646\u062f.<\/li>\n\n\n\n<li>\u0642\u062f\u0645 \u067e\u0646\u062c\u0645: \u0639\u0645\u0644\u06af\u0631 \u0627\u0646\u062a\u062e\u0627\u0628 \u0634\u062f\u0647 \u062a\u0648\u0633\u0637 \u06a9\u0627\u0631\u0628\u0631 \u0631\u0627 \u0628\u0631\u0627\u06cc \u0645\u062a\u063a\u06cc\u0631\u0647\u0627\u06cc \u0648\u0631\u0648\u062f\u06cc \u0627\u0639\u0645\u0627\u0644 \u06a9\u0646\u062f.<\/li>\n\n\n\n<li>\u0642\u062f\u0645 \u0634\u0634\u0645: \u0646\u062a\u0627\u06cc\u062c \u0631\u0627 \u062f\u0631 \u0645\u062a\u063a\u06cc\u0631 res \u0630\u062e\u06cc\u0631\u0647 \u06a9\u0646\u062f.<\/li>\n\n\n\n<li>\u0642\u062f\u0645 \u0647\u0641\u062a\u0645: \u0646\u062a\u06cc\u062c\u0647 \u0631\u0627 \u0646\u0645\u0627\u06cc\u0634 \u062f\u0647\u062f.<\/li>\n\n\n\n<li>\u0642\u062f\u0645 \u0647\u0634\u062a\u0645: \u0628\u0631\u0646\u0627\u0645\u0647 \u0645\u062a\u0648\u0642\u0641 \u0634\u0648\u062f.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u0631\u0648\u0634\u200c\u0647\u0627\u06cc \u0646\u0648\u0634\u062a\u0646 \u06a9\u062f \u0628\u0631\u0646\u0627\u0645\u0647 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0628\u0647 \u0632\u0628\u0627\u0646 c<\/h2>\n\n\n\n<p>\u0686\u0646\u062f\u06cc\u0646 \u0631\u0648\u0634 \u0628\u0631\u0627\u06cc \u0646\u0648\u0634\u062a\u0646 <strong>\u06a9\u062f \u0628\u0631\u0646\u0627\u0645\u0647 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0628\u0647 \u0632\u0628\u0627\u0646 c<\/strong> \u0648\u062c\u0648\u062f \u062f\u0627\u0631\u062f \u0648\u0644\u06cc \u0627\u0644\u06af\u0648\u0631\u06cc\u062a\u0645 \u062a\u0645\u0627\u0645\u06cc \u0622\u0646\u200c\u0647\u0627 \u0645\u0634\u0627\u0628\u0647 \u0627\u0633\u062a :<br>\n\u2022 \u0646\u0648\u0634\u062a\u0646 \u06a9\u062f \u0628\u0631\u0646\u0627\u0645\u0647 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0628\u0647 \u0632\u0628\u0627\u0646 c \u0628\u0627 \u062f\u0633\u062a\u0648\u0631 if else if<br>\n\u2022 \u0646\u0648\u0634\u062a\u0646 \u0628\u0631\u0646\u0627\u0645\u0647 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0628\u0647 \u0632\u0628\u0627\u0646 c \u0628\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062f\u0633\u062a\u0648\u0631 \u062d\u0644\u0642\u0647 \u0648 \u0633\u0648\u0626\u06cc\u0686 do-while<br>\n\u2022 \u0646\u0648\u0634\u062a\u0646 \u0628\u0631\u0646\u0627\u0645\u0647 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0628\u0647 \u0632\u0628\u0627\u0646 c \u0628\u0627 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u062a\u0627\u0628\u0639 \u0648 \u062f\u0633\u062a\u0648\u0631 \u0633\u0648\u0626\u06cc\u0686<br>\n\u2022 \u0646\u0648\u0634\u062a\u0646 \u06a9\u062f \u0628\u0631\u0646\u0627\u0645\u0647 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0628\u0647 \u0632\u0628\u0627\u0646 c \u0628\u0627 \u062f\u0633\u062a\u0648\u0631 switch<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u062f\u0631 \u0627\u06cc\u0646 \u0645\u0637\u0644\u0628 \u0631\u0648\u0634 \u0622\u062e\u0631 \u0631\u0627 \u0628\u0627 \u06cc\u06a9 \u0645\u062b\u0627\u0644 \u0628\u0631\u0631\u0633\u06cc \u062e\u0648\u0627\u0647\u06cc\u0645 \u06a9\u0631\u062f:<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>\n<p style=\"text-align: left;\">#include &lt;stdio.h&gt;<\/p>\n<p style=\"text-align: left;\">int main()<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">\/\/ declare local variables<\/p>\n<p style=\"text-align: left;\">char opt;<\/p>\n<p style=\"text-align: left;\">int n1, n2;<\/p>\n<p style=\"text-align: left;\">float res;<\/p>\n<p style=\"text-align: left;\">printf (&#8221; Choose an operator(+, -, *, \/) to perform the operation in C Calculator \\n &#8220;);<\/p>\n<p style=\"text-align: left;\">scanf (&#8220;%c&#8221;, &amp;opt); \/\/ take an operator<\/p>\n<p style=\"text-align: left;\">if (opt == &#8216;\/&#8217; )<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">printf (&#8221; You have selected: Division&#8221;);<\/p>\n<p style=\"text-align: left;\">}<\/p>\n<p style=\"text-align: left;\">else if (opt == &#8216;*&#8217;)<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">printf (&#8221; You have selected: Multiplication&#8221;);<\/p>\n<p style=\"text-align: left;\">}<\/p>\n<p style=\"text-align: left;\">else if (opt == &#8216;-&#8216;)<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">printf (&#8221; You have selected: Subtraction&#8221;);<\/p>\n<p style=\"text-align: left;\">}<\/p>\n<p style=\"text-align: left;\">else if (opt == &#8216;+&#8217;)<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">printf (&#8221; You have selected: Addition&#8221;);<\/p>\n<p style=\"text-align: left;\">}<\/p>\n<p style=\"text-align: left;\">printf (&#8221; \\n Enter the first number: &#8220;);<\/p>\n<p style=\"text-align: left;\">scanf(&#8221; %d&#8221;, &amp;n1); \/\/ take fist number<\/p>\n<p style=\"text-align: left;\">printf (&#8221; Enter the second number: &#8220;);<\/p>\n<p style=\"text-align: left;\">scanf (&#8221; %d&#8221;, &amp;n2); \/\/ take second number<\/p>\n<p style=\"text-align: left;\">switch(opt)<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">case &#8216;+&#8217;:<\/p>\n<p style=\"text-align: left;\">res = n1 + n2; \/\/ add two numbers<\/p>\n<p style=\"text-align: left;\">printf (&#8221; Addition of %d and %d is: %.2f&#8221;, n1, n2, res);<\/p>\n<p style=\"text-align: left;\">break;<\/p>\n<p style=\"text-align: left;\">case &#8216;-&#8216;:<\/p>\n<p style=\"text-align: left;\">res = n1 &#8211; n2; \/\/ subtract two numbers<\/p>\n<p style=\"text-align: left;\">printf (&#8221; Subtraction of %d and %d is: %.2f&#8221;, n1, n2, res);<\/p>\n<p style=\"text-align: left;\">break;<\/p>\n<p style=\"text-align: left;\">case &#8216;*&#8217;:<\/p>\n<p style=\"text-align: left;\">res = n1 * n2; \/\/ multiply two numbers<\/p>\n<p style=\"text-align: left;\">printf (&#8221; Multiplication of %d and %d is: %.2f&#8221;, n1, n2, res);<\/p>\n<p style=\"text-align: left;\">break;<\/p>\n<p style=\"text-align: left;\">case &#8216;\/&#8217;:<\/p>\n<p style=\"text-align: left;\">if (n2 == 0)&nbsp;&nbsp; \/\/ if n2 == 0, take another number<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">printf (&#8221; \\n Divisor cannot be zero. Please enter another value &#8220;);<\/p>\n<p style=\"text-align: left;\">scanf (&#8220;%d&#8221;, &amp;n2);<\/p>\n<p style=\"text-align: left;\">}<\/p>\n<p style=\"text-align: left;\">res = n1 \/ n2; \/\/ divide two numbers<\/p>\n<p style=\"text-align: left;\">printf (&#8221; Division of %d and %d is: %.2f&#8221;, n1, n2, res);<\/p>\n<p style=\"text-align: left;\">break;<\/p>\n<p style=\"text-align: left;\">default:&nbsp; \/* use default to print default message if any condition is not satisfied *\/<\/p>\n<p style=\"text-align: left;\">printf (&#8221; Something is wrong!! Please check the options &#8220;);<\/p>\n<p style=\"text-align: left;\">}<\/p>\n<p style=\"text-align: left;\">return 0;<\/p>\n<p style=\"text-align: left;\">}<\/p>\n<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u06a9\u062f \u0628\u0627\u0644\u0627 \u0628\u0627 \u062f\u0633\u062a\u0648\u0631 switch \u0628\u0631\u0646\u0627\u0645\u0647\u200c\u200c\u06cc \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0631\u0627 \u0628\u0647 \u0632\u0628\u0627\u0646 c \u0645\u06cc\u200c\u200c\u0646\u0648\u06cc\u0633\u062f \u06a9\u0647 \u062f\u0648 \u0639\u062f\u062f \u0631\u0627 \u06af\u0631\u0641\u062a\u0647 \u0648 \u0645\u06cc\u200c\u200c\u062a\u0648\u0627\u0646\u062f \u0686\u0647\u0627\u0631 \u0639\u0645\u0644 \u0627\u0635\u0644\u06cc \u0631\u0627 \u0628\u0631\u0627\u06cc<br>\n\u0622\u0646\u200c\u200c\u0647\u0627 \u0627\u0639\u0645\u0627\u0644 \u06a9\u0646\u062f. \u062e\u0631\u0648\u062c\u06cc \u0627\u06cc\u0646 \u0628\u0631\u0646\u0627\u0645\u0647 \u0628\u0647 \u0634\u06a9\u0644 \u0632\u06cc\u0631 \u062e\u0648\u0627\u0647\u062f \u0628\u0648\u062f:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img fetchpriority=\"high\" decoding=\"async\" width=\"630\" height=\"143\" src=\"https:\/\/maktabkhooneh.org\/mag\/wp-content\/uploads\/2021\/11\/1-19.jpg\" alt=\"\u06a9\u062f \u0628\u0631\u0646\u0627\u0645\u0647 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0628\u0647 \u0632\u0628\u0627\u0646 c\" class=\"wp-image-27250\" title=\"\" srcset=\"https:\/\/maktabkhooneh.org\/mag\/wp-content\/uploads\/2021\/11\/1-19.jpg 630w, https:\/\/maktabkhooneh.org\/mag\/wp-content\/smush-webp\/2021\/11\/1-19-300x68.jpg.webp 300w\" sizes=\"(max-width: 630px) 100vw, 630px\" \/><figcaption><\/figcaption><\/figure>\n\n\n\n<p>\u062a\u0648\u062c\u0647 \u062f\u0627\u0634\u062a\u0647 \u0628\u0627\u0634\u06cc\u062f \u06a9\u0647 \u062f\u0631 \u062f\u0633\u062a\u0648\u0631\u0627\u0644\u0639\u0645\u0644 switch \u062d\u062a\u0645\u0627 \u0628\u0627\u06cc\u062f \u067e\u0627\u06cc\u0627\u0646 \u0647\u0631 \u062f\u0633\u062a\u0648\u0631\u060cbreak \u0628\u0627\u0634\u062f.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u0633\u0648\u0631\u0633 \u06a9\u062f \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0645\u0647\u0646\u062f\u0633\u06cc \u0628\u0647 \u0632\u0628\u0627\u0646 c++:<\/h2>\n\n\n\n<p>\u0628\u0627 \u06a9\u0645\u06a9 \u0632\u0628\u0627\u0646 c++\u200e \u0646\u06cc\u0632 \u0645\u06cc\u200c\u200c\u062a\u0648\u0627\u0646\u06cc\u0645 \u06a9\u062f\u06cc \u0628\u0631\u0627\u06cc \u0627\u06cc\u062c\u0627\u062f \u06cc\u06a9 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0628\u0646\u0648\u06cc\u0633\u06cc\u0645. \u0627\u0644\u06af\u0648\u0631\u06cc\u062a\u0645 \u06a9\u062f\u0646\u0648\u06cc\u0633\u06cc \u0645\u0627\u0646\u0646\u062f \u06af\u0630\u0634\u062a\u0647 \u0627\u0633\u062a \u0648 \u0627\u06cc\u0646 \u0628\u0627\u0631 \u0647\u0645 \u0627\u0632 \u062f\u0633\u062a\u0648\u0631 switch \u0628\u0631\u0627\u06cc \u0646\u0648\u0634\u062a\u0646 \u0628\u0631\u0646\u0627\u0645\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc\u200c\u200c\u06a9\u0646\u06cc\u0645\u060c \u0628\u0627 \u0627\u06cc\u0646 \u062a\u0641\u0627\u0648\u062a \u06a9\u0647 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0627\u06cc\u062c\u0627\u062f \u0634\u062f\u0647 \u0639\u0644\u0627\u0648\u0647 \u0628\u0631 \u0686\u0647\u0627\u0631 \u0639\u0645\u0644 \u0627\u0635\u0644\u06cc \u0628\u062a\u0648\u0627\u0646\u062f \u0645\u0631\u0628\u0639 \u0648 \u062c\u0630\u0631 \u0639\u062f\u062f \u0648\u0631\u0648\u062f\u06cc \u0631\u0627 \u0646\u06cc\u0632 \u0645\u062d\u0627\u0633\u0628\u0647 \u06a9\u0646\u062f.<\/p>\n\n\n<div class=\"jet-listing-grid--50121\" style=\"\"><div class=\"jet-listing-dynamic-field-block zht-maktab-khooneh-course cb-fb2qc30r\"data-is-block=\"jet-engine\/dynamic-field\"><div class=\"jet-listing-dynamic-field__content\" >\n<div class=\"course-card\">\n    <div class=\"course-card-img\">\n        <img decoding=\"async\" \n            data-src=\"https:\/\/media1.maktabkhooneh.org\/CACHE\/images\/courses\/images\/C_card_1403-08-16-164658679\/4948bf79c99237119b4727880a0a5125.webp?expire=4893471932&#038;token=e23eb6ff27391a546be83880706eb9e3&#038;md5=4j62_yc5GlRr6DiAcG654w==\" \n            alt=\"\u0622\u0645\u0648\u0632\u0634 \u0628\u0631\u0646\u0627\u0645\u0647\u200c\u0646\u0648\u06cc\u0633\u06cc C++\" \n            title=\"\u0622\u0645\u0648\u0632\u0634 \u0628\u0631\u0646\u0627\u0645\u0647\u200c\u0646\u0648\u06cc\u0633\u06cc C++\" \n            width=\"100%\" \n            height=\"auto\"\n           \n         src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\">\n    <\/div>\n\n    <div class=\"course-details\">\n        <a href=\"https:\/\/maktabkhooneh.org\/course\/%D8%A8%D8%B1%D9%86%D8%A7%D9%85%D9%87-%D9%86%D9%88%DB%8C%D8%B3%DB%8C-%D8%B2%D8%A8%D8%A7%D9%86-c-plus-plus-mk361\/\" class=\"course-title\" target=\"_blank\" rel=\"noopener noreferrer\">\n            \u0622\u0645\u0648\u0632\u0634 \u0628\u0631\u0646\u0627\u0645\u0647\u200c\u0646\u0648\u06cc\u0633\u06cc C++        <\/a>\n\n        <div class=\"course-price\">\n            \n                <span class=\"real-price\">\n                                            \u06f1,\u06f8\u06f9\u06f9,\u06f0\u06f0\u06f0                                    <\/span>\n\n                <span>\n                    <span class=\"discounted-price\">\n                        \u06f8\u06f5\u06f4,\u06f5\u06f5\u06f0                    <\/span>\n                    <span class=\"price-currency\">\u062a\u0648\u0645\u0627\u0646<\/span>\n                <\/span>\n\n                                    <div class=\"discount-percentage\">\n                        \u06f5\u06f5%                    <\/div>\n                \n                    <\/div>\n        <button class=\"course-cta-button\" data-course-url=\"https:\/\/maktabkhooneh.org\/course\/%D8%A8%D8%B1%D9%86%D8%A7%D9%85%D9%87-%D9%86%D9%88%DB%8C%D8%B3%DB%8C-%D8%B2%D8%A8%D8%A7%D9%86-c-plus-plus-mk361\/\">\n            \u0645\u0634\u0627\u0647\u062f\u0647 \u0648 \u062e\u0631\u06cc\u062f        <\/button>\n    <\/div>\n<\/div>\n<\/div><\/div><\/div>\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>\n<p style=\"text-align: left;\">#include&lt;iostream.h&gt;<\/p>\n<p style=\"text-align: left;\">#include&lt;stdio.h&gt;<\/p>\n<p style=\"text-align: left;\">#include&lt;conio.h&gt;<\/p>\n<p style=\"text-align: left;\">#include&lt;math.h&gt;<\/p>\n<p style=\"text-align: left;\">#include&lt;stdlib.h&gt;<\/p>\n<p style=\"text-align: left;\">void add();<\/p>\n<p style=\"text-align: left;\">void sub();<\/p>\n<p style=\"text-align: left;\">void multi();<\/p>\n<p style=\"text-align: left;\">void division();<\/p>\n<p style=\"text-align: left;\">void sqr();<\/p>\n<p style=\"text-align: left;\">void srt();<\/p>\n<p style=\"text-align: left;\">void exit();<\/p>\n<p style=\"text-align: left;\">void main()<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">clrscr();<\/p>\n<p style=\"text-align: left;\">int opr;<\/p>\n<p style=\"text-align: left;\">\/\/ display different operation of the calculator<\/p>\n<p style=\"text-align: left;\">do<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt; &#8220;Select any operation from the C++ Calculator&#8221;<\/p>\n<p style=\"text-align: left;\">&#8220;\\n1 = Addition&#8221;<\/p>\n<p style=\"text-align: left;\">&#8220;\\n2 = Subtraction&#8221;<\/p>\n<p style=\"text-align: left;\">&#8220;\\n3 = Multiplication&#8221;<\/p>\n<p style=\"text-align: left;\">&#8220;\\n4 = Division&#8221;<\/p>\n<p style=\"text-align: left;\">&#8220;\\n5 = Square&#8221;<\/p>\n<p style=\"text-align: left;\">&#8220;\\n6 = Square Root&#8221;<\/p>\n<p style=\"text-align: left;\">&#8220;\\n7 = Exit&#8221;<\/p>\n<p style=\"text-align: left;\">&#8220;\\n \\n Make a choice: &#8220;;<\/p>\n<p style=\"text-align: left;\">cin &gt;&gt; opr;<\/p>\n<p style=\"text-align: left;\">switch (opr)<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">case 1:<\/p>\n<p style=\"text-align: left;\">add();&nbsp;&nbsp; \/\/ call add() function to find the Addition<\/p>\n<p style=\"text-align: left;\">break;<\/p>\n<p style=\"text-align: left;\">case 2:<\/p>\n<p style=\"text-align: left;\">sub();&nbsp;&nbsp; \/\/ call sub() function to find the subtraction<\/p>\n<p style=\"text-align: left;\">break;<\/p>\n<p style=\"text-align: left;\">case 3:<\/p>\n<p style=\"text-align: left;\">multi(); \/\/ call multi() function to find the multiplication<\/p>\n<p style=\"text-align: left;\">break;<\/p>\n<p style=\"text-align: left;\">case 4:<\/p>\n<p style=\"text-align: left;\">division(); \/\/ call division() function to find the division<\/p>\n<p style=\"text-align: left;\">break;<\/p>\n<p style=\"text-align: left;\">case 5:<\/p>\n<p style=\"text-align: left;\">sqr(); \/\/ call sqr() function to find the square of a number<\/p>\n<p style=\"text-align: left;\">break;<\/p>\n<p style=\"text-align: left;\">case 6:<\/p>\n<p style=\"text-align: left;\">srt(); \/\/ call srt() function to find the Square Root of the given number<\/p>\n<p style=\"text-align: left;\">break;<\/p>\n<p style=\"text-align: left;\">case 7:<\/p>\n<p style=\"text-align: left;\">exit(0);&nbsp;&nbsp; \/\/ terminate the program<\/p>\n<p style=\"text-align: left;\">break;<\/p>\n<p style=\"text-align: left;\">default:<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt;&#8220;Something is wrong..!!&#8221;;<\/p>\n<p style=\"text-align: left;\">break;<\/p>\n<p style=\"text-align: left;\">}<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt;&#8221; \\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;\\n&#8221;;<\/p>\n<p style=\"text-align: left;\">}while(opr != 7);<\/p>\n<p style=\"text-align: left;\">getch();<\/p>\n<p style=\"text-align: left;\">}<\/p>\n<p style=\"text-align: left;\">void add()<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">int n, sum = 0, i, number;<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt;&#8220;How many numbers you want to add: &#8220;;<\/p>\n<p style=\"text-align: left;\">cin &gt;&gt; n;<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt; &#8220;Please enter the number one by one: \\n&#8221;;<\/p>\n<p style=\"text-align: left;\">for (i = 1; i &lt;= n; i++)<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">cin &gt;&gt; number;<\/p>\n<p style=\"text-align: left;\">sum = sum + number;<\/p>\n<p style=\"text-align: left;\">}<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt; &#8220;\\n Sum of the numbers = &#8220;&lt;&lt; sum;<\/p>\n<p style=\"text-align: left;\">}<\/p>\n<p style=\"text-align: left;\">void sub()<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">int num1, num2, z;<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt;&#8221; \\n Enter the First number = &#8220;;<\/p>\n<p style=\"text-align: left;\">cin &gt;&gt; num1;<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt; &#8220;\\n Enter the Second number = &#8220;;<\/p>\n<p style=\"text-align: left;\">cin &gt;&gt; num2;<\/p>\n<p style=\"text-align: left;\">z = num1 &#8211; num2;<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt;&#8220;\\n Subtraction of the number = &#8221; &lt;&lt; z;<\/p>\n<p style=\"text-align: left;\">}<\/p>\n<p style=\"text-align: left;\">void multi()<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">int num1, num2, mul;<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt;&#8221; \\n Enter the First number = &#8220;;<\/p>\n<p style=\"text-align: left;\">cin &gt;&gt; num1;<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt; &#8220;\\n Enter the Second number = &#8220;;<\/p>\n<p style=\"text-align: left;\">cin &gt;&gt; num2;<\/p>\n<p style=\"text-align: left;\">mul = num1 * num2;<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt;&#8220;\\n Multiplication of two numbers = &#8221; &lt;&lt; mul;<\/p>\n<p style=\"text-align: left;\">}<\/p>\n<p style=\"text-align: left;\">void division()<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">int num1, num2, div = 0;<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt;&#8221; \\n Enter the First number = &#8220;;<\/p>\n<p style=\"text-align: left;\">cin &gt;&gt; num1;<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt; &#8220;\\n Enter the Second number = &#8220;;<\/p>\n<p style=\"text-align: left;\">cin &gt;&gt; num2;<\/p>\n<p style=\"text-align: left;\">while ( num2 == 0)<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt; &#8220;\\n Divisor canot be zero&#8221;<\/p>\n<p style=\"text-align: left;\">&#8220;\\n Please enter the divisor once again: &#8220;;<\/p>\n<p style=\"text-align: left;\">cin &gt;&gt; num2;<\/p>\n<p style=\"text-align: left;\">}<\/p>\n<p style=\"text-align: left;\">div = num1 \/ num2;<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt;&#8220;\\n Division of two numbers = &#8221; &lt;&lt; div;<\/p>\n<p style=\"text-align: left;\">}<\/p>\n<p style=\"text-align: left;\">void sqr()<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">int num1;<\/p>\n<p style=\"text-align: left;\">float sq;<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt;&#8221; \\n Enter a number to find the Square: &#8220;;<\/p>\n<p style=\"text-align: left;\">cin &gt;&gt; num1;<\/p>\n<p style=\"text-align: left;\">sq = num1 * num1;<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt;&#8221; \\n Square of &#8221; &lt;&lt; num1&lt;&lt; &#8221; is : &#8220;&lt;&lt; sq;<\/p>\n<p style=\"text-align: left;\">}<\/p>\n<p style=\"text-align: left;\">void srt()<\/p>\n<p style=\"text-align: left;\">{<\/p>\n<p style=\"text-align: left;\">float q;<\/p>\n<p style=\"text-align: left;\">int num1;<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt; &#8220;\\n Enter the number to find the Square Root:&#8221;;<\/p>\n<p style=\"text-align: left;\">cin &gt;&gt; num1;<\/p>\n<p style=\"text-align: left;\">q = sqrt(num1);<\/p>\n<p style=\"text-align: left;\">cout &lt;&lt;&#8221; \\n Square Root of &#8221; &lt;&lt; num1&lt;&lt; &#8221; is : &#8220;&lt;&lt; q;<\/p>\n<p style=\"text-align: left;\">}<\/p>\n<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u062e\u0631\u0648\u062c\u06cc \u0628\u0631\u0646\u0627\u0645\u0647 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0628\u0647 \u0632\u0628\u0627\u0646 c++ \u0628\u0647 \u0635\u0648\u0631\u062a \u0632\u06cc\u0631 \u062e\u0648\u0627\u0647\u062f \u0628\u0648\u062f:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" width=\"644\" height=\"748\" data-src=\"https:\/\/maktabkhooneh.org\/mag\/wp-content\/uploads\/2021\/11\/2-20.jpg\" alt=\"\u06a9\u062f \u0628\u0631\u0646\u0627\u0645\u0647 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0628\u0647 \u0632\u0628\u0627\u0646 c\" class=\"wp-image-27249 lazyload\" title=\"\" data-srcset=\"https:\/\/maktabkhooneh.org\/mag\/wp-content\/uploads\/2021\/11\/2-20.jpg 644w, https:\/\/maktabkhooneh.org\/mag\/wp-content\/smush-webp\/2021\/11\/2-20-258x300.jpg.webp 258w\" data-sizes=\"(max-width: 644px) 100vw, 644px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 644px; --smush-placeholder-aspect-ratio: 644\/748;\" \/><figcaption><\/figcaption><\/figure>\n\n\n","protected":false},"excerpt":{"rendered":"<p>\u06a9\u062f \u0628\u0631\u0646\u0627\u0645\u0647 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0628\u0647 \u0632\u0628\u0627\u0646 c \u062f\u0631 \u0627\u06cc\u0646 \u0645\u0642\u0627\u0644\u0647 \u0645\u06cc\u200c\u062e\u0648\u0627\u0647\u06cc\u0645 \u0628\u0647 \u0646\u062d\u0648\u0647 \u0646\u0648\u0634\u062a\u0646 \u06a9\u062f \u0628\u0631\u0646\u0627\u0645\u0647 \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0628\u0647 \u0632\u0628\u0627\u0646 c \u0628\u067e\u0631\u062f\u0627\u0632\u06cc\u0645. \u0647\u0645\u0627\u0646\u0637\u0648\u0631 \u06a9\u0647 \u0645\u06cc\u200c\u062f\u0627\u0646\u06cc\u062f \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628 \u0646\u0631\u0645\u200c\u0627\u0641\u0632\u0627\u0631 \u0633\u0627\u062f\u0647\u200c\u0627\u06cc \u0627\u0633\u062a \u06a9\u0647 \u0628\u0631\u0627\u06cc \u0627\u0646\u062c\u0627\u0645 \u0639\u0645\u06cc\u0627\u062a\u200c\u0647\u0627\u06cc \u0645\u062e\u062a\u0644\u0641 \u0645\u0627\u0646\u0646\u062f \u062c\u0645\u0639 \u060c \u062a\u0641\u0631\u06cc\u0642 \u060c \u0636\u0631\u0628 \u060c \u062a\u0642\u0633\u06cc\u0645 \u060c \u062f\u0631\u0635\u062f \u0648 &#8230; \u0628\u0647 \u06a9\u0627\u0631\u0645\u06cc\u200c\u0631\u0648\u062f. \u0645\u0627\u0634\u06cc\u0646 \u062d\u0633\u0627\u0628\u200c\u0647\u0627\u06cc \u067e\u06cc\u0686\u06cc\u062f\u0647\u200c\u062a\u0631 \u0645\u06cc\u200c\u062a\u0648\u0627\u0646\u0646\u062f \u0628\u0631\u0627\u06cc \u0645\u062d\u0627\u0633\u0628\u0627\u062a [&hellip;]<\/p>\n","protected":false},"author":35,"featured_media":27251,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,19],"tags":[],"class_list":["post-27248","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming-and-it-training","category-c-cpp-c-sharp-articles"],"_links":{"self":[{"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/posts\/27248","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/comments?post=27248"}],"version-history":[{"count":4,"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/posts\/27248\/revisions"}],"predecessor-version":[{"id":66360,"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/posts\/27248\/revisions\/66360"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/media\/27251"}],"wp:attachment":[{"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/media?parent=27248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/categories?post=27248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/maktabkhooneh.org\/mag\/wp-json\/wp\/v2\/tags?post=27248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}