{"id":9826,"date":"2023-10-03T14:36:04","date_gmt":"2023-10-03T14:36:04","guid":{"rendered":"https:\/\/adelnasim.com\/docs\/courses\/cpp-tutorial\/selection-statement-9820\/else\/"},"modified":"2024-04-07T01:19:21","modified_gmt":"2024-04-07T01:19:21","slug":"else","status":"publish","type":"docs","link":"https:\/\/adelnasim.com\/ar\/docs\/courses\/cpp-tutorial\/selection-statements\/else\/","title":{"rendered":"else"},"content":{"rendered":"<div class=\"logo-gutter ng-tns-c3907565777-98 ng-star-inserted\">\n<div class=\"resize-observable\"><\/div>\n<\/div>\n<div class=\"response-container-content ng-tns-c3907565777-98\">\n<div class=\"response-content ng-trigger ng-trigger-responsePopulation ng-tns-c3907565777-98\">\n<div class=\"markdown markdown-main-panel\" dir=\"ltr\">\n<p data-sourcepos=\"1:1-1:136\">\u0627\u0644\u0640 <code>else<\/code> \u062a\u064f\u0633\u062a\u062e\u062f\u0645 \u0641\u064a \u0644\u063a\u0629 C++ \u0644\u062a\u0648\u0641\u064a\u0631 \u0645\u062c\u0645\u0648\u0639\u0629 \u0628\u062f\u064a\u0644\u0629 \u0645\u0646 \u0627\u0644\u062a\u0639\u0644\u064a\u0645\u0627\u062a \u0627\u0644\u0628\u0631\u0645\u062c\u064a\u0629  \u0648\u0627\u0644\u0630\u064a \u064a\u062a\u0645 \u062a\u0646\u0641\u064a\u0630\u0647\u0627 \u0625\u0630\u0627 \u0643\u0627\u0646 \u0634\u0631\u0637 \u062c\u0645\u0644\u0629 <code>if<\/code> \u062e\u0627\u0637\u0626\u064b\u0627.<\/p>\n<p data-sourcepos=\"3:1-3:56\">\u0628\u0646\u0627\u0621 \u062c\u0645\u0644\u0629 <code>else<\/code> \u0647\u0648 \u0643\u0627\u0644\u062a\u0627\u0644\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;}\">if (condition) {\r\n  \/\/ code to execute if the condition is true\r\n} else {\r\n  \/\/ code to execute if the condition is false\r\n}<\/pre>\n<\/div>\n<p data-sourcepos=\"3:1-3:56\">\u0639\u0644\u0649 \u0633\u0628\u064a\u0644 \u0627\u0644\u0645\u062b\u0627\u0644\u060c \u064a\u0633\u062a\u062e\u062f\u0645 \u0627\u0644\u0628\u0631\u0646\u0627\u0645\u062c \u0627\u0644\u062a\u0627\u0644\u064a \u062c\u0645\u0644\u0629 <code>else<\/code> \u0644\u0637\u0628\u0627\u0639\u0629 \u0631\u0633\u0627\u0644\u0629 \u0645\u062e\u062a\u0644\u0641\u0629 \u0627\u0639\u062a\u0645\u0627\u062f\u064b\u0627 \u0639\u0644\u0649 \u0645\u0627 \u0625\u0630\u0627 \u0643\u0627\u0646 \u0645\u062a\u063a\u064a\u0631 <span style=\"color: #222222; font-family: monospace;\"><span style=\"background-color: #e9ebec;\">\u0627\u0644\u0631\u0642\u0645 x <\/span><\/span>\u0639\u062f\u062f\u064b\u0627 \u0645\u0648\u062c\u0628\u064b\u0627 \u0623\u0645 \u0633\u0627\u0644\u0628\u064b\u0627:<\/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;\r\n    cin &gt;&gt; x;\r\n    if (x &gt; 0)\r\n        cout &lt;&lt; \"This number is positive\" &lt;&lt; endl;\r\n    else\r\n        cout &lt;&lt; \"This number is negative\" &lt;&lt; endl;\r\n\r\n\r\n    return 0;\r\n}<\/pre>\n<\/div>\n<p data-sourcepos=\"3:1-3:56\">\u064a\u062c\u0628 \u0623\u0646 \u062a\u0643\u0648\u0646 \u0645\u062e\u0631\u062c\u0627\u062a \u0623\u062d\u062f \u0627\u0644\u0639\u0628\u0627\u0631\u0627\u062a \u0627\u0644\u0633\u0627\u0628\u0642\u0629 \u062d\u0633\u0628 \u0627\u0644\u0631\u0642\u0645 \u0627\u0644\u0645\u062f\u062e\u0644. \u0625\u0630\u0627 \u0643\u0627\u0646 \u0627\u0644\u0631\u0642\u0645 \u0645\u0648\u062c\u0628\u064b\u0627 \u0645\u062b\u0644 5\u060c \u0641\u0633\u064a\u0643\u0648\u0646 \u0627\u0644\u0646\u0627\u062a\u062c  \u201cThis number is positive\u201d \u0648\u0627\u0644\u0639\u0643\u0633 \u0635\u062d\u064a\u062d.<\/p>\n<p data-sourcepos=\"3:1-3:56\">\u0627\u0644\u0640 <code>else<\/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<\/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=\"55:1-55: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>if else<\/code> \u0627\u0644\u0634\u0631\u0637\u064a\u0651\u0629:<\/p>\n<ul data-sourcepos=\"57:1-60:0\">\n<li data-sourcepos=\"57:1-57:74\">\u0627\u0644\u0640\u00a0<code>else<\/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=\"58:1-58:136\">\u0627\u0644\u0640\u00a0<code>else<\/code>\u00a0\u064a\u0645\u0643\u0646 \u0627\u0633\u062a\u062e\u062f\u0627\u0645\u0647\u0627 \u0644\u062a\u0648\u0641\u064a\u0631 \u0645\u062c\u0645\u0648\u0639\u0629 \u0628\u062f\u064a\u0644\u0629 \u0645\u0646 \u0627\u0644\u062a\u0639\u0644\u064a\u0645\u0627\u062a \u0627\u0644\u0628\u0631\u0645\u062c\u064a\u0629 \u0648\u0627\u0644\u062a\u064a \u064a\u062a\u0645 \u062a\u0646\u0641\u064a\u0630\u0647\u0627 \u0625\u0630\u0627 \u0643\u0627\u0646 \u0627\u0644\u0634\u0631\u0637 \u0641\u064a \u062c\u0645\u0644\u0629\u00a0<code>if<\/code>\u00a0\u062e\u0627\u0637\u0626\u064b\u0627.<\/li>\n<li data-sourcepos=\"59:1-60: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>if else<\/code> \u0644\u0625\u0646\u0634\u0627\u0621 \u062c\u0645\u0644\u0629 \u0634\u0631\u0637\u064a\u0629 \u0623\u0643\u062b\u0631 \u062a\u0639\u0642\u064a\u062f\u064b\u0627:\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;\r\n    cin &gt;&gt; x;\r\n    if (x % 2 == 0)\r\n        if (x &gt; 50)\r\n            cout &lt;&lt; \"it's Ok\" &lt;&lt; endl;\r\n        else\r\n            cout &lt;&lt; \"it's not Ok\" &lt;&lt; endl;\r\n    else\r\n        cout &lt;&lt; \"Odd\" &lt;&lt; endl;\r\n\r\n\r\n    return 0;\r\n}\r\n<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<p data-sourcepos=\"61:1-61: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>if else<\/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>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>The else statement in C++ is used to provide an alternate block of code to be executed if the condition of an if statement is false. The general syntax of an else statement is as follows: if (condition) { \/\/ code to execute if the condition is true } else { \/\/ code to execute [&hellip;]<\/p>","protected":false},"author":3,"featured_media":0,"parent":9820,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-9826","docs","type-docs","status-publish","hentry","no-post-thumbnail"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/9826","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=9826"}],"version-history":[{"count":5,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/9826\/revisions"}],"predecessor-version":[{"id":9839,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/docs\/9826\/revisions\/9839"}],"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=9826"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/adelnasim.com\/ar\/wp-json\/wp\/v2\/doc_tag?post=9826"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}