{"id":5077,"date":"2021-11-12T10:27:09","date_gmt":"2021-11-12T10:27:09","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=5077"},"modified":"2021-11-12T10:27:45","modified_gmt":"2021-11-12T10:27:45","slug":"break-statement-is-not-within-loop-or-switch","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/break-statement-is-not-within-loop-or-switch\/29840.html","title":{"rendered":"Break Statement Is Not Within Loop Or Switch"},"content":{"rendered":"<p>i&#8217;m still new with c program and language, i&#8217;m learning it by myself.<br \/>\ncan anyone tell my why it state that break statement is not within loop or switch.<\/p>\n<p>#include &lt;stdio.h&gt;<br \/>\n#include &lt;string.h&gt;<\/p>\n<p>int main()<br \/>\n{<br \/>\nchar password[14] = &#8220;student14&#8221;;<br \/>\nchar input_user[14];<br \/>\nchar name[20];<br \/>\nchar system;<br \/>\nchar security_code[20] = &#8220;270792&#8221;;<br \/>\nchar input_security[20];<br \/>\nint x;<br \/>\nint y;<\/p>\n<p>printf(&#8220;Please input your name and password. \\n&#8221;);<br \/>\nprintf(&#8220;Name:&#8221;);scanf(&#8220;%[^\\n]&#8221;, name);<br \/>\nfflush(stdin);<\/p>\n<p>for (x = 0; x &lt; 3; x++)<br \/>\n{<br \/>\nprintf(&#8220;Password:&#8221;);scanf(&#8220;%[^\\n]&#8221;, input_user);<br \/>\nfflush(stdin);<\/p>\n<p>if (strcmp (input_user, password) == 0)<br \/>\nbreak;<br \/>\nelse<br \/>\nprintf(&#8220;Access Denied\\n&#8221;);<\/p>\n<p>}<\/p>\n<p>if (strcmp (input_user, password) == 0)<br \/>\n{<br \/>\nprintf(&#8220;Access Granted&#8221;);<\/p>\n<p>}<br \/>\nelse<br \/>\n{<br \/>\nfor (y = 0; y &lt; 10; y++);<br \/>\n{<br \/>\nprintf(&#8220;Please input your security code\\n&#8221;);<br \/>\nprintf(&#8220;Security Code: &#8220;);scanf(&#8220;%[^\\n]&#8221;, input_security);<\/p>\n<p>if (strcmp (input_security, security_code) == 0)<br \/>\nbreak;<br \/>\nelse<br \/>\nprintf(&#8220;Access Denied\\n&#8221;);<\/p>\n<p>}<br \/>\n}<\/p>\n<p>printf(&#8220;Access Granted.\\nCongratulation you finaly able to enter you program.&#8221;);<\/p>\n<p>getchar();<br \/>\nfflush(stdin);<br \/>\nreturn 0;<br \/>\n}<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":5},"question-category":[55],"question_tags":[],"class_list":["post-5077","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/5077","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=5077"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=5077"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=5077"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=5077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}