{"id":9457,"date":"2023-09-12T21:50:36","date_gmt":"2023-09-12T21:50:36","guid":{"rendered":"https:\/\/adelnasim.com\/docs\/courses\/elements\/array\/"},"modified":"2024-04-07T01:19:18","modified_gmt":"2024-04-07T01:19:18","slug":"basic-arithmetic-and-casting","status":"publish","type":"docs","link":"https:\/\/adelnasim.com\/ar\/docs\/courses\/cpp-tutorial\/basic-arithmetic-and-casting\/","title":{"rendered":"\u0627\u0644\u0639\u0645\u0644\u064a\u0627\u062a \u0627\u0644\u062d\u0633\u0627\u0628\u064a\u0629 \u0648\u0627\u0644\u062a\u062d\u0648\u064a\u0644\u0627\u062a \u0627\u0644\u062d\u0633\u0627\u0628\u064a\u0629 \u0627\u0644\u0623\u0633\u0627\u0633\u064a\u0629"},"content":{"rendered":"<p data-sourcepos=\"1:1-1:27\"><strong>\u0627\u0644\u0639\u0645\u0644\u064a\u0627\u062a \u0627\u0644\u062d\u0633\u0627\u0628\u064a\u0629 \u0627\u0644\u0623\u0633\u0627\u0633\u064a\u0629 \u0641\u064a \u0644\u063a\u0629 C++<\/strong><\/p>\n<p data-sourcepos=\"3:1-3:103\">\u062a\u0642\u062f\u0645 \u0644\u063a\u0629 C++ \u0639\u062f\u062f\u064b\u0627 \u0645\u0646 \u0627\u0644\u0639\u0648\u0627\u0645\u0644 \u0627\u0644\u062a\u064a \u062a\u0645\u062b\u0644 \u0627\u0644\u0639\u0645\u0644\u064a\u0627\u062a \u0627\u0644\u062d\u0633\u0627\u0628\u064a\u0629 \u0627\u0644\u0623\u0633\u0627\u0633\u064a\u0629. \u062a\u0634\u0645\u0644 \u0647\u0630\u0647 \u0627\u0644\u0639\u0648\u0627\u0645\u0644:<\/p>\n<ul data-sourcepos=\"5:1-10:0\">\n<li data-sourcepos=\"5:1-5:17\"><strong>+:<\/strong>\u00a0\u0627\u0644\u062c\u0645\u0639<\/li>\n<li data-sourcepos=\"6:1-6:20\"><strong>-:<\/strong>\u00a0\u0627\u0644\u0637\u0631\u062d<\/li>\n<li data-sourcepos=\"7:1-7:23\">*<strong>:<\/strong>\u00a0\u0627\u0644\u0636\u0631\u0628<\/li>\n<li data-sourcepos=\"8:1-8:17\"><strong>\/:<\/strong>\u00a0\u0627\u0644\u0642\u0633\u0645\u0629<\/li>\n<li data-sourcepos=\"9:1-10:0\"><strong>%:<\/strong>\u00a0\u0645\u0639\u0627\u0645\u0644 \u0627\u0644\u0642\u0633\u0645\u0629 (\u0627\u0644\u0628\u0627\u0642\u064a)<\/li>\n<\/ul>\n<p data-sourcepos=\"11:1-11:197\">\u064a\u0645\u0643\u0646 \u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0647\u0630\u0647 \u0627\u0644\u0639\u0648\u0627\u0645\u0644 \u0644\u0625\u062c\u0631\u0627\u0621 \u0639\u0645\u0644\u064a\u0627\u062a \u062d\u0633\u0627\u0628\u064a\u0629 \u0639\u0644\u0649 \u0645\u062a\u063a\u064a\u0631\u0627\u062a \u0645\u0646 \u0623\u0646\u0648\u0627\u0639 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0627\u0644\u0645\u062e\u062a\u0644\u0641\u0629. \u0639\u0644\u0649 \u0633\u0628\u064a\u0644 \u0627\u0644\u0645\u062b\u0627\u0644\u060c \u064a\u0646\u0641\u0630 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c \u0627\u0644\u062a\u0627\u0644\u064a \u0639\u0645\u0644\u064a\u0627\u062a \u062d\u0633\u0627\u0628\u064a\u0629 \u0639\u0644\u0649 \u0645\u062a\u063a\u064a\u0631\u0627\u062a \u0645\u0646 \u0627\u0644\u0646\u0648\u0639 int \u0648 float:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block\">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;htmlmixed&quot;,&quot;mime&quot;:&quot;text\/html&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">int a = 10;\r\nfloat b = 3.14159;\r\n\r\n\/\/ Add two integers.\r\nint c = a + 5;\r\n\r\n\/\/ Multiply two floats.\r\nfloat d = b * 2;\r\n\r\n\/\/ Divide two integers.\r\nfloat e = a \/ 2;\r\n\r\n\/\/ Calculate the remainder of a division operation.\r\nint f = a % 2;<\/pre>\n<\/div>\n<p data-sourcepos=\"30:1-30:74\">\u064a\u062a\u0645 \u062a\u062e\u0632\u064a\u0646 \u0646\u062a\u0627\u0626\u062c \u0647\u0630\u0647 \u0627\u0644\u0639\u0645\u0644\u064a\u0627\u062a \u0641\u064a \u0627\u0644\u0645\u062a\u063a\u064a\u0631\u0627\u062a \u0627\u0644\u0645\u0642\u0627\u0628\u0644\u0629.<\/p>\n<p data-sourcepos=\"32:1-32:18\"><strong>\u0627\u0644\u062a\u062d\u0648\u064a\u0644\u0627\u062a \u0627\u0644\u062d\u0633\u0627\u0628\u064a\u0629 Casting \u0641\u064a \u0644\u063a\u0629 C++<\/strong><\/p>\n<p data-sourcepos=\"34:1-34:167\">\u0627\u0644\u062a\u062d\u0648\u064a\u0644 Casting \u0647\u0648 \u0637\u0631\u064a\u0642\u0629 \u0644\u062a\u062d\u0648\u064a\u0644 \u0642\u064a\u0645\u0629 \u0645\u0646 \u0646\u0648\u0639 \u0628\u064a\u0627\u0646\u0627\u062a \u0625\u0644\u0649 \u0622\u062e\u0631. \u064a\u0645\u0643\u0646 \u0623\u0646 \u064a\u0643\u0648\u0646 \u0647\u0630\u0627 \u0645\u0641\u064a\u062f\u064b\u0627 \u0639\u0646\u062f\u0645\u0627 \u062a\u062d\u062a\u0627\u062c \u0625\u0644\u0649 \u0625\u062c\u0631\u0627\u0621 \u0639\u0645\u0644\u064a\u0627\u062a \u062d\u0633\u0627\u0628\u064a\u0629 \u0639\u0644\u0649 \u0642\u064a\u0645 \u0623\u0646\u0648\u0627\u0639 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0627\u0644\u0645\u062e\u062a\u0644\u0641\u0629.<\/p>\n<p data-sourcepos=\"36:1-36:38\">\u0647\u0646\u0627\u0643 \u0646\u0648\u0639\u0627\u0646 \u0645\u0646 \u0627\u0644\u062a\u062d\u0648\u064a\u0644\u0627\u062a Casting \u0641\u064a \u0644\u063a\u0629 C++:<\/p>\n<ul data-sourcepos=\"38:1-39:0\">\n<li data-sourcepos=\"38:1-39:0\"><strong>\u0627\u0644\u062a\u062d\u0648\u064a\u0644 \u0627\u0644\u0636\u0645\u0646\u064a:<\/strong>\u00a0\u064a\u062d\u062f\u062b \u0627\u0644\u062a\u062d\u0648\u064a\u0644 \u0627\u0644\u0636\u0645\u0646\u064a \u0639\u0646\u062f\u0645\u0627 \u064a\u0642\u0648\u0645 \u0627\u0644\u0645\u062a\u0631\u062c\u0645 \u062a\u0644\u0642\u0627\u0626\u064a\u064b\u0627 \u0628\u062a\u062d\u0648\u064a\u0644 \u0642\u064a\u0645\u0629 \u0645\u0646 \u0646\u0648\u0639 \u0628\u064a\u0627\u0646\u0627\u062a \u0625\u0644\u0649 \u0622\u062e\u0631. \u0639\u0644\u0649 \u0633\u0628\u064a\u0644 \u0627\u0644\u0645\u062b\u0627\u0644\u060c \u064a\u0642\u0648\u0645 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c \u0627\u0644\u062a\u0627\u0644\u064a \u0636\u0645\u0646\u064a\u064b\u0627 \u0628\u062a\u062d\u0648\u064a\u0644 \u0642\u064a\u0645\u0629 \u0627\u0644\u0645\u062a\u063a\u064a\u0631\u00a0<code>a<\/code>\u00a0\u0645\u0646 \u0627\u0644\u0646\u0648\u0639 int \u0625\u0644\u0649 \u0627\u0644\u0646\u0648\u0639 float \u0642\u0628\u0644 \u0625\u062c\u0631\u0627\u0621 \u0639\u0645\u0644\u064a\u0629 \u0627\u0644\u0636\u0631\u0628:<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<div class=\"wp-block-codemirror-blocks code-block\">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;htmlmixed&quot;,&quot;mime&quot;:&quot;text\/html&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">int a = 10;\r\nfloat b = 3.14159;\r\n\r\n\/\/ Multiply an int and a float.\r\nfloat c = a * b;<\/pre>\n<\/div>\n<ul>\n<li data-sourcepos=\"48:1-49:0\"><strong>\u0627\u0644\u062a\u062d\u0648\u064a\u0644 \u0627\u0644\u0635\u0631\u064a\u062d:<\/strong>\u00a0\u064a\u062d\u062f\u062b \u0627\u0644\u062a\u062d\u0648\u064a\u0644 \u0627\u0644\u0635\u0631\u064a\u062d \u0639\u0646\u062f\u0645\u0627 \u064a\u0642\u0648\u0645 \u0627\u0644\u0645\u0628\u0631\u0645\u062c \u0628\u062a\u062d\u0648\u064a\u0644 \u0642\u064a\u0645\u0629 \u0628\u0634\u0643\u0644 \u0635\u0631\u064a\u062d \u0645\u0646 \u0646\u0648\u0639 \u0628\u064a\u0627\u0646\u0627\u062a \u0625\u0644\u0649 \u0622\u062e\u0631. \u064a\u0645\u0643\u0646 \u0627\u0644\u0642\u064a\u0627\u0645 \u0628\u0630\u0644\u0643 \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0627\u0644\u0639\u0648\u0627\u0645\u0644 \u0627\u0644\u062a\u0627\u0644\u064a\u0629 (<code>static_cast<\/code>,\u00a0<code>reinterpret_cast<\/code>,\u00a0<code>const_cast<\/code>\u060c \u0648\u00a0<code>dynamic_cast<\/code>). \u0639\u0644\u0649 \u0633\u0628\u064a\u0644 \u0627\u0644\u0645\u062b\u0627\u0644\u060c \u064a\u0642\u0648\u0645 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c \u0627\u0644\u062a\u0627\u0644\u064a \u0628\u0634\u0643\u0644 \u0635\u0631\u064a\u062d \u0628\u062a\u062d\u0648\u064a\u0644 \u0642\u064a\u0645\u0629 \u0627\u0644\u0645\u062a\u063a\u064a\u0631\u00a0<code>b<\/code>\u00a0\u0645\u0646 \u0627\u0644\u0646\u0648\u0639 float \u0625\u0644\u0649 \u0627\u0644\u0646\u0648\u0639 int \u0642\u0628\u0644 \u0625\u062c\u0631\u0627\u0621 \u0639\u0645\u0644\u064a\u0629 \u0627\u0644\u0642\u0633\u0645\u0629:<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<div class=\"wp-block-codemirror-blocks code-block\">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;htmlmixed&quot;,&quot;mime&quot;:&quot;text\/html&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">int a = 10;\r\nfloat b = 3.14159;\r\n\r\n\/\/ Divide a float by an int.\r\nint c = static_cast&lt;int&gt;(b) \/ a;<\/pre>\n<\/div>\n<p data-sourcepos=\"58:1-58:95\">\u063a\u0627\u0644\u0628\u064b\u0627 \u0645\u0627 \u064a\u062a\u0645 \u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0627\u0644\u062a\u062d\u0648\u064a\u0644 \u0627\u0644\u0635\u0631\u064a\u062d \u0644\u0645\u0646\u0639 \u0627\u0644\u0623\u062e\u0637\u0627\u0621 \u0627\u0644\u062a\u064a \u064a\u0645\u0643\u0646 \u0623\u0646 \u062a\u062d\u062f\u062b \u0639\u0646\u062f \u062a\u062d\u0648\u064a\u0644 \u0627\u0644\u0642\u064a\u0645 \u0636\u0645\u0646\u064a\u064b\u0627.<\/p>\n<p data-sourcepos=\"60:1-60:12\"><strong>\u0645\u062b\u0627\u0644<\/strong><\/p>\n<p data-sourcepos=\"62:1-62:52\">\u0641\u064a\u0645\u0627 \u064a\u0644\u064a \u0645\u062b\u0627\u0644 \u0644\u0643\u064a\u0641\u064a\u0629 \u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u0627\u0644\u062a\u062d\u0648\u064a\u0644 \u0641\u064a C++:<\/p>\n<div class=\"wp-block-codemirror-blocks code-block\">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;htmlmixed&quot;,&quot;mime&quot;:&quot;text\/html&quot;,&quot;theme&quot;:&quot;default&quot;,&quot;lineNumbers&quot;:false,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\">\/\/ Convert a string to an integer.\r\nint a = static_cast&lt;int&gt;(\"10\");\r\n\r\n\/\/ Convert a floating-point number to a character.\r\nchar b = static_cast&lt;char&gt;(3.14159);\r\n\r\n\/\/ Convert a pointer to an integer to a pointer to a float.\r\nfloat *c = reinterpret_cast&lt;float*&gt;(pInt);\r\n\r\n\/\/ Convert a const object to a non-const object.\r\nint *d = const_cast&lt;int*&gt;(pInt);<\/pre>\n<\/div>\n<p data-sourcepos=\"62:1-62:52\">\u064a\u0645\u0643\u0646 \u0623\u0646 \u064a\u0643\u0648\u0646 \u0627\u0644\u062a\u062d\u0648\u064a\u0644 \u0623\u062f\u0627\u0629 \u0642\u0648\u064a\u0629 \u0644\u062a\u062d\u0648\u064a\u0644 \u0627\u0644\u0642\u064a\u0645 \u0628\u064a\u0646 \u0623\u0646\u0648\u0627\u0639 \u0627\u0644\u0628\u064a\u0627\u0646\u0627\u062a \u0627\u0644\u0645\u062e\u062a\u0644\u0641\u0629. \u0648\u0645\u0639 \u0630\u0644\u0643\u060c \u0641\u0645\u0646 \u0627\u0644\u0645\u0647\u0645 \u0627\u0633\u062a\u062e\u062f\u0627\u0645\u0647 \u0628\u0639\u0646\u0627\u064a\u0629 \u0644\u062a\u062c\u0646\u0628 \u0627\u0644\u0623\u062e\u0637\u0627\u0621.<\/p>","protected":false},"excerpt":{"rendered":"<p>Basic Arithmetic in C++ C++ provides a number of operators for performing basic arithmetic operations. These operators include: +:\u00a0Addition -:\u00a0Subtraction *:\u00a0Multiplication \/:\u00a0Division %:\u00a0Modulo (remainder) These operators can be used to perform arithmetic operations on variables of different data types. For example, the following code performs arithmetic operations on variables of type int and float: int [&hellip;]<\/p>","protected":false},"author":1,"featured_media":0,"parent":2744,"menu_order":7,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-9457","docs","type-docs","status-publish","hentry","no-post-thumbnail"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/9457","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/comments?post=9457"}],"version-history":[{"count":9,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/9457\/revisions"}],"predecessor-version":[{"id":10258,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/9457\/revisions\/10258"}],"up":[{"embeddable":true,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/2744"}],"wp:attachment":[{"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/media?parent=9457"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/doc_tag?post=9457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}