{"id":9824,"date":"2023-10-03T14:34:14","date_gmt":"2023-10-03T14:34:14","guid":{"rendered":"https:\/\/adelnasim.com\/docs\/courses\/cpp-tutorial\/selection-statement-9820\/if-else\/"},"modified":"2024-04-07T01:19:21","modified_gmt":"2024-04-07T01:19:21","slug":"if-else","status":"publish","type":"docs","link":"https:\/\/adelnasim.com\/ar\/docs\/courses\/cpp-tutorial\/selection-statements\/if-else\/","title":{"rendered":"else if"},"content":{"rendered":"<div tabindex=\"0\" aria-hidden=\"true\"><\/div>\n<div class=\"cdk-visually-hidden cdk-focus-trap-anchor\" tabindex=\"0\" aria-hidden=\"true\">\u0627\u0644\u0640 <code>else if<\/code> \u0647\u064a \u0639\u0628\u0627\u0631\u0629 \u0634\u0631\u0637\u064a\u0629 \u062a\u0633\u0645\u062d \u0644\u0643 \u0628\u062a\u0646\u0641\u064a\u0630 \u0645\u062c\u0645\u0648\u0639\u0627\u062a \u0645\u062e\u062a\u0644\u0641\u0629 \u0645\u0646 \u0627\u0644\u062a\u0639\u0644\u064a\u0645\u0627\u062a \u0627\u0644\u0628\u0631\u0645\u062c\u064a\u0629 \u0628\u0646\u0627\u0621\u064b \u0639\u0644\u0649 \u0633\u0644\u0633\u0644\u0629 \u0645\u0646 \u0627\u0644\u0634\u0631\u0648\u0637. \u0628\u0646\u0627\u0621 \u0627\u0644\u062c\u0645\u0644\u0629 \u0627\u0644\u0639\u0627\u0645 \u0644\u0640 <code>else if<\/code> \u0647\u0648 \u0643\u0627\u0644\u062a\u0627\u0644\u064a:<\/div>\n<div tabindex=\"0\" aria-hidden=\"true\">\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;}\">if (condition1) {\r\n  \/\/ code to execute if condition1 is true\r\n} else if (condition2) {\r\n  \/\/ code to execute if condition1 is false and condition2 is true\r\n} else if (condition3) {\r\n  \/\/ code to execute if condition1 and condition2 are false and condition3 is true\r\n} ...\r\nelse {\r\n  \/\/ code to execute if none of the conditions are true\r\n}<\/pre>\n<\/div>\n<p data-sourcepos=\"16:1-16:221\">\u0627\u0644\u0640 <code>else if<\/code> \u064a\u062a\u0645 \u0627\u0644\u0645\u0631\u0648\u0631 \u0639\u0644\u064a\u0647\u0627 \u0648\u062a\u0646\u0641\u064a\u0630\u0647\u0627 \u0628\u0627\u0644\u062a\u0631\u062a\u064a\u0628\u060c \u062d\u064a\u062b \u0623\u0646 \u0623\u0648\u0644 \u062c\u0645\u0644\u0629 <code>else if<\/code> \u062a\u0643\u0648\u0646 \u0635\u062d\u064a\u062d\u0629 <code>true<\/code> \u064a\u062a\u0645 \u062a\u0646\u0641\u064a\u0630\u0647\u0627. \u0648\u0625\u0630\u0627 \u0644\u0645 \u062a\u0643\u0646 \u0623\u064a \u0648\u0627\u062d\u062f\u0629 \u0645\u0646 \u062c\u0645\u0644 <code>else if<\/code> \u0630\u0627\u062a \u0642\u064a\u0645\u0629 \u0635\u062d\u064a\u062d\u0629 <code>true<\/code>\u064a\u0635\u0644 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c \u0625\u0644\u0649 \u062c\u0645\u0644\u0629 <code>else<\/code> \u0633\u064a\u062a\u0645 \u062a\u0646\u0641\u064a\u0630\u0647\u0627.<\/p>\n<p data-sourcepos=\"18:1-18:45\">\u0647\u0630\u0627 \u0645\u062b\u0627\u0644 \u0639\u0644\u0649 \u062c\u0645\u0644\u0629 <code>else if<\/code> \u0627\u0644\u0634\u0631\u0637\u064a\u0651\u0629:<\/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;}\">#include &lt;iostream&gt;\r\n\r\nusing namespace std;\r\n\r\nint main()\r\n{\r\n    int mark = 0;\r\n    cin &gt;&gt; mark;\r\n    if (mark &gt;= 90)\r\n        cout &lt;&lt; \"A\" &lt;&lt; endl;\r\n    else if (mark &gt;= 80)\r\n        cout &lt;&lt; \"B\" &lt;&lt; endl;\r\n    else if (mark &gt;= 70)\r\n        cout &lt;&lt; \"C\" &lt;&lt; endl;\r\n    else if (mark &gt;= 60)\r\n        cout &lt;&lt; \"D\" &lt;&lt; endl;\r\n    else\r\n        cout &lt;&lt; \"F\" &lt;&lt; endl;\r\n\r\n    return 0;\r\n}<\/pre>\n<\/div>\n<p data-sourcepos=\"18:1-18:45\">\u0645\u062b\u0627\u0644 \u0625\u0636\u0627\u0641\u064a:<\/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;}\">#include &lt;iostream&gt;\r\n\r\nusing namespace std;\r\n\r\nint main()\r\n{\r\n    int x = 0, y = 0;\r\n    cout &lt;&lt; \"Enter 2 numbers\" &lt;&lt; endl;\r\n    cin &gt;&gt; x &gt;&gt; y;\r\n    if (x &lt; y)\r\n        cout &lt;&lt; \"y is greater than x\" &lt;&lt; endl;\r\n    else if (x &gt; y)\r\n        cout &lt;&lt; \"x is greater than y\" &lt;&lt; endl;\r\n\r\n    else\r\n        cout &lt;&lt; \"Both are equal\" &lt;&lt; endl;\r\n    \r\n    cout &lt;&lt; \"C++ is great language!\" &lt;&lt; endl;\r\n\r\n\r\n\r\n    return 0;\r\n}\r\n<\/pre>\n<\/div>\n<p data-sourcepos=\"42:1-42:96\">\u064a\u064f\u0645\u0643\u0646 \u0625\u0633\u062a\u062e\u062f\u0627\u0645 \u062c\u064f\u0645\u064e\u0644 \u0645\u062a\u062f\u0627\u062e\u0644\u0629 \u0645\u0646 <code>else if<\/code> \u0627\u0644\u0634\u0631\u0637\u064a\u0629 \u0644\u0625\u0646\u0634\u0627\u0621 \u062c\u064f\u0645\u064e\u0644 \u0634\u0631\u0637\u064a\u0629 \u0623\u0643\u062b\u0631 \u062a\u0639\u0642\u064a\u062f\u064b\u0627.<\/p>\n<p data-sourcepos=\"44:1-44:162\">\u0627\u0644\u0640 <code>else if<\/code> \u062a\u064f\u0639\u064e\u062f \u0623\u062f\u0627\u0629 \u0642\u0648\u064a\u0629 \u0644\u0644\u062a\u062d\u0643\u0645 \u0641\u064a \u062a\u062f\u0641\u0642 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c. \u0628\u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u062c\u0645\u0644\u0629 <code>else if<\/code> \u060c \u064a\u0645\u0643\u0646\u0643 \u0643\u062a\u0627\u0628\u0629 \u0643\u0648\u062f \u0623\u0643\u062b\u0631 \u062a\u0639\u0642\u064a\u062f\u064b\u0627 \u0648\u0641\u0639\u0627\u0644\u064a\u0629.<\/p>\n<p data-sourcepos=\"46:1-46:62\">\u0641\u064a\u0645\u0627 \u064a\u0644\u064a \u0628\u0639\u0636 \u0627\u0644\u0642\u0648\u0627\u0639\u062f \u0627\u0644\u0639\u0627\u0645\u0629 \u0644\u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u062c\u0645\u0644\u0629 <code>else if<\/code> \u0627\u0644\u0634\u0631\u0637\u064a\u0651\u0629:<\/p>\n<ul data-sourcepos=\"48:1-52:0\">\n<li data-sourcepos=\"48:1-48:77\">\u0627\u0644\u0640\u00a0<code>else if<\/code>\u00a0\u064a\u062c\u0628 \u0627\u0633\u062a\u062e\u062f\u0627\u0645\u0647\u0627 \u0628\u0627\u0644\u062a\u0632\u0627\u0645\u0646 \u0645\u0639 \u062c\u0645\u0644\u0629\u00a0<code>if<\/code>\u00a0.<\/li>\n<li data-sourcepos=\"49:1-49:133\">\u0627\u0644\u0640\u00a0<code>else if<\/code>\u00a0\u064a\u062a\u0645 \u0627\u0644\u0645\u0631\u0648\u0631 \u0639\u0644\u064a\u0647\u0627 \u0648\u062a\u0646\u0641\u064a\u0630\u0647\u0627 \u0628\u0627\u0644\u062a\u0631\u062a\u064a\u0628\u060c \u062d\u064a\u062b \u0623\u0646 \u0623\u0648\u0644 \u062c\u0645\u0644\u0629\u00a0<code>else if<\/code>\u00a0\u062a\u0643\u0648\u0646 \u0635\u062d\u064a\u062d\u0629\u00a0<code>true<\/code>\u00a0\u064a\u062a\u0645 \u062a\u0646\u0641\u064a\u0630\u0647\u0627<\/li>\n<li data-sourcepos=\"50:1-50:91\">\u0625\u0630\u0627 \u0644\u0645 \u062a\u0643\u0646 \u0623\u064a \u0645\u0646 \u062c\u064f\u0645\u064e\u0644\u00a0<code>else if<\/code>\u00a0\u0630\u0627\u062a \u0642\u064a\u0645\u0629 \u0635\u062d\u064a\u062d\u0629\u00a0<code>true<\/code>\u064a\u0635\u0644 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c \u0625\u0644\u0649 \u062c\u0645\u0644\u0629\u00a0<code>else<\/code>\u00a0\u0633\u064a\u062a\u0645 \u062a\u0646\u0641\u064a\u0630\u0647\u0627.<\/li>\n<li data-sourcepos=\"51:1-52:0\">\u064a\u0645\u0643\u0646\u0643 \u0627\u0633\u062a\u062e\u062f\u0627\u0645 \u062c\u0645\u0644 \u0634\u0631\u0637\u064a\u0629 \u0645\u062a\u062f\u0627\u062e\u0644\u0629 \u062f\u0627\u062e\u0644 \u062c\u0645\u0644\u0629\u00a0<code>else if<\/code>\u00a0\u0627\u0644\u0634\u0631\u0637\u064a\u0629 \u0644\u0625\u0646\u0634\u0627\u0621 \u062c\u064f\u0645\u064e\u0644 \u0634\u0631\u0637\u064a\u0629 \u0623\u0643\u062b\u0631 \u062a\u0639\u0642\u064a\u062f\u064b\u0627.<\/li>\n<\/ul>\n<p data-sourcepos=\"53:1-53:104\">\u0645\u0646 \u062e\u0644\u0627\u0644 \u0641\u0647\u0645 \u0643\u064a\u0641\u064a\u0629 \u0625\u0633\u062a\u062e\u062f\u0627\u0645 \u062c\u0645\u0644\u0629 <code>else if<\/code> \u060c \u062a\u0633\u062a\u0637\u064a\u0639 \u0643\u062a\u0627\u0628\u0629 \u0643\u0648\u062f \u0623\u0643\u062b\u0631 \u0643\u0641\u0627\u0621\u0629 \u0648\u0641\u0627\u0639\u0644\u064a\u0651\u0629.<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>The else if statement in C++ is a conditional statement that allows you to execute different blocks of code based on a series of conditions. The general syntax of an else if statement is as follows: if (condition1) { \/\/ code to execute if condition1 is true } else if (condition2) { \/\/ code to [&hellip;]<\/p>","protected":false},"author":3,"featured_media":0,"parent":9820,"menu_order":3,"comment_status":"closed","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-9824","docs","type-docs","status-publish","hentry","no-post-thumbnail"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/9824","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\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/comments?post=9824"}],"version-history":[{"count":4,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/9824\/revisions"}],"predecessor-version":[{"id":10558,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/9824\/revisions\/10558"}],"up":[{"embeddable":true,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/9820"}],"wp:attachment":[{"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/media?parent=9824"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/doc_tag?post=9824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}