On this mastery I will show you what a FOR loop in C++ is and how to use it.<\/p>\n
A FOR loop is a type of loop which allows you to give specific conditions to it, and then repeat when this conditions are true.\u00a0 Now, let\u2019s create a program which displays the factorial of a given number. Factorial is the result of the multiplication of all numbers starting from 1 to the number you want to know its factorial. For example, 5 factorial is 1 x 2 x 3 x 4 x 5 which = 120.\u00a0<\/p>\n Let\u2019s make that program using a for loop, so do as follows:<\/p>\n Your code should look something like this:<\/p>\n Now lets test the program with factorial 5, which should be equal to 120.<\/p>\n That\u2019s it, you now know how to use a for loop, congrats!<\/p>\n","protected":false},"excerpt":{"rendered":" On this mastery I will show you what a FOR loop in C++ is and how to use it.<\/p>\n A FOR loop is a type of loop which allows you to give specific conditions to it, and then repeat when this conditions are true. Now, let’s create a program which displays the factorial of a given number. Factorial is the result of the multiplication of all numbers starting from 1 to the number you want to know its factorial. For example, 5 factorial is 1 x 2 x 3 x 4 x 5 which = 120. <\/p>\n Let’s make that program using a for loop, so do as follows:<\/p>\n Your code should look something like this:<\/p>\n Now lets test the program with factorial 5, which should be equal to 120.<\/p>\n That’s it, you now know how to use a for loop, congrats!<\/p>\n","protected":false},"author":230,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3],"tags":[219,171,40,611],"class_list":["post-25208","post","type-post","status-publish","format-standard","hentry","category-blogs","category-syndicated","tag-c","tag-mastery20","tag-tc1017","tag-hashtag"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/25208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/users\/230"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/comments?post=25208"}],"version-history":[{"count":1,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/25208\/revisions"}],"predecessor-version":[{"id":25209,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/25208\/revisions\/25209"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/media?parent=25208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/categories?post=25208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/tags?post=25208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
A for loop consists of four parts: an initializer (declaration of what happens first to the variable; it only happens once), a condition (evaluates and proceeds with the code if its true, if not it will stop), an incremet (this updates the variable after the code is completed and increments the variable), and the statement (what will happen when the conditions are true). In a flow chart, for loops look something like this:<\/p>\n
<\/figure>\n\n
<\/figure>\n
<\/figure>\n
A for loop consists of four parts: an initializer (declaration of what happens first to the variable; it only happens once), a condition (evaluates and proceeds with the code if its true, if not it will stop), an incremet (this updates the variable after the code is completed and increments the variable), and the statement (what will happen when the conditions are true). In a flow chart, for loops look something like this:<\/p>\n
<\/figure>\n\n
<\/figure>\n
<\/figure>\n