{"id":32134,"date":"2016-02-17T19:04:29","date_gmt":"2016-02-18T01:04:29","guid":{"rendered":"http:\/\/everolivares.wordpress.com\/?p=170"},"modified":"2016-02-17T19:59:56","modified_gmt":"2016-02-18T01:59:56","slug":"wsq09-factorial-calculator-7","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101winter2016\/2016\/02\/wsq09-factorial-calculator-7\/","title":{"rendered":"#WSQ09-Factorial calculator"},"content":{"rendered":"<p>Create a program that asks the user for a non-negative integer (let\u2019s call that number n) and display for them the value of n! (n factorial).<\/p>\n<p>After showing them the answer, ask them if they would like to try another number (with a simple y\/n response) and either ask again (for y) or quit the program and wish them a nice day (if they answered n).<\/p>\n<p>This where my instructions. And this is how I what I did.<\/p>\n<p>This program accepts a &#8220;n&#8221; positive number and multiplies it in a sequence for example: 5!=102, this is also 1 x 2 x 3 x 4 x 5=120.<\/p>\n<p>Also this program has a loop that ends with the sequence of the multiplications.<\/p>\n<p>\/\/CODE:<\/p>\n<p>#include &lt;iostream&gt;<br \/>\nusing namespace std;<\/p>\n<p>int main(int argc, char const *argv[]) {<br \/>\nint n, n2, conta;<br \/>\nchar ans;<br \/>\nstd::cout &lt;&lt; &#8220;This program prints the factorial of &lt;n&gt; number.&#8221; &lt;&lt; std::endl;<br \/>\ndo {<br \/>\nstd::cout &lt;&lt; &#8220;Please enter a non-negative number to calculate the factorial.&#8221; &lt;&lt; std::endl;<br \/>\nstd::cin &gt;&gt; n;<br \/>\nif (n==0) {<br \/>\nstd::cout &lt;&lt; &#8220;The factorial is&#8230; 1&#8221; &lt;&lt; std::endl; \/\/cuando corro el programa sale factorial is&#8230; 1 y despu\u00e9s factorial is&#8230; 0 y despues vulve a preguntar&#8230;.<br \/>\n}<br \/>\nconta=n;<br \/>\ndo {<br \/>\nconta=conta-1;<br \/>\nn=n*conta;<br \/>\n} while(conta !=1);<br \/>\nstd::cout &lt;&lt; &#8220;The factorial is&#8230; &#8220;&lt;&lt;n &lt;&lt; std::endl;<br \/>\nstd::cout &lt;&lt; &#8220;Do you like to add another factorial? Write &lt;y&gt; for yes and &lt;n&lt; for no&#8221; &lt;&lt; std::endl;<br \/>\nstd::cin &gt;&gt; ans;<\/p>\n<p>} while(ans==&#8217;y&#8217;);<\/p>\n<p>return 0;<br \/>\n}<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-176\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/02\/15578f4090894f0392fbe5d316020efd.jpg\" alt=\"Captura de pantalla 2016-02-17 a las 18.58.58\"   \/><\/p>\n<p>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/everolivares.wordpress.com\/170\/\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/02\/4b95e4963e12275d36f5335883ba8587.jpg\" \/><\/a> <img loading=\"lazy\" decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/02\/5de1459ff14826c9eaccbee98c72bd58.jpg#038;blog=105236756&#038;%23038;post=170&#038;%23038;subd=everolivares&#038;%23038;ref=&#038;%23038;feed=1\" width=\"1\" height=\"1\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Create a program that asks the user for a non-negative integer (let\u2019s call that number n) and display for them the value of n! (n factorial). After showing them the answer, ask them if they would like to try another number (with a simple y\/n response) and either ask again (for y) or quit the &hellip; <a href=\"https:\/\/kenscourses.com\/tc101winter2016\/2016\/02\/wsq09-factorial-calculator-7\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">#WSQ09-Factorial calculator<\/span><\/a><\/p>\n","protected":false},"author":58,"featured_media":32154,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[25,41],"class_list":["post-32134","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogs","category-syndicated","tag-uncategorized","tag-wsqs"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/32134","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/users\/58"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/comments?post=32134"}],"version-history":[{"count":2,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/32134\/revisions"}],"predecessor-version":[{"id":32158,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/32134\/revisions\/32158"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/media\/32154"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/media?parent=32134"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/categories?post=32134"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/tags?post=32134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}