{"id":38511,"date":"2016-05-14T10:54:43","date_gmt":"2016-05-14T15:54:43","guid":{"rendered":"http:\/\/lilihecblog.wordpress.com\/?p=125"},"modified":"2016-05-15T07:34:48","modified_gmt":"2016-05-15T12:34:48","slug":"wsq13-2-parcial","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101winter2016\/2016\/05\/wsq13-2-parcial\/","title":{"rendered":"WSQ13- 2 Parcial"},"content":{"rendered":"<p>Aqu\u00ed esta resuleto correctamente el examen de segundo parcial, y con las instrucciones de como realizarlo:<\/p>\n<p>QUESTION 1:<\/p>\n<p>Write a function called triangles which receives a single parameter (int) which represents the size of a triangle as explained below. The function should print a triangle using loops (for or while). The only characters printed here are \u2018T\u2019 and the new-line character. The first line is length one, the middle line is length size and the last line is length one. The example below is for size 6.<\/p>\n<p>\/\/CODE<\/p>\n<p>\/\/ Ever Olivares<br \/>\n#include &lt;stdio.h&gt;<br \/>\n#include &lt;iostream&gt;<br \/>\nusing namespace std;<\/p>\n<p>int triangle (int x)<br \/>\n{<br \/>\nfor (int i=1; i&lt;=x ;i++)<br \/>\n{<br \/>\nfor (int j=1; j&lt;i+1; j++)<br \/>\ncout &lt;&lt;\u201cT\u201d; cout &lt;&lt;endl;<br \/>\n}<br \/>\nfor (int i=x-1; i&gt;=1; i\u2013)<br \/>\n{<br \/>\nfor (int j=1; j&lt;i+1; j++)<br \/>\ncout &lt;&lt;\u201cT\u201d; cout &lt;&lt;endl;<br \/>\n}<br \/>\nreturn 0;<br \/>\n}<br \/>\nint main ()<br \/>\n{<br \/>\nint y;<br \/>\nstd::cout&lt;&lt;\u201ctype the numbers of T you want\u201d &lt;&lt;std::endl;<br \/>\nstd::cin &gt;&gt; y;<br \/>\ntriangle (y);<br \/>\n}<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-130\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/b3735ab3b0963dbf899325a6f7bdab1e.jpg\" alt=\"Captura de pantalla 2016-05-14 a las 10.51.57.png\"   \/><\/p>\n<p>&nbsp;<\/p>\n<p>QUESTION 2:<\/p>\n<p>Write a function called superpower that has two parameters of type long and returns a long which is first parameter raised to the power of the second, which is to say it returns ab So, superpower(3,4) would return 81.<\/p>\n<p>\/\/CODE:<\/p>\n<p>\/\/ Ever Oliavres<br \/>\n#include &lt;iostream&gt;<br \/>\n#include &lt;cmath&gt;<\/p>\n<p>void superpower(int num1, int num2){<br \/>\nint R;<br \/>\nR= pow(3,4);<br \/>\nstd::cout &lt;&lt; \u201cThe result is\u2026 \u201c&lt;&lt;R &lt;&lt; std::endl;<br \/>\n}<\/p>\n<p>int main(int argc, char const *argv[]) {<br \/>\nint R;<br \/>\nsuperpower(3,4);<\/p>\n<p>return 0;<br \/>\n}<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-133\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/5391659124a93debdb4f5daa8dc1c1fd.jpg\" alt=\"Captura de pantalla 2016-05-14 a las 10.52.42.png\"   \/><\/p>\n<p>QUESTION 3:<\/p>\n<p>Write a function called fibonacci which receives a long \u201cn\u201d and returns a long which is the value of the nth number in the fibonacci series which is: 0,1,1,2,3,5,8,13,21,34,55,89\u2026\u2026\u2026\u2026So, fibonacci(0) would return 0. fibonacci(5) would return 5, fibonacci(8) would return 21.Note that the first two fibonacci numbers are 0 and All others are the sum of the <\/p>\n<div class=\"post-limited-image\"><img decoding=\"async\" class=\"alignnone size-full wp-image-137\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/14c9d35f42062f89d5904c63c27d2e32.jpg\" alt=\"Captura de pantalla 2016-05-14 a las 10.53.33.png\"   \/><\/div>\n<div class=\"post-limited-image\"><img decoding=\"async\" class=\"alignnone size-full wp-image-140\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/bdc0787499c3bea18e5cb3ae19ff1ed2.jpg\" alt=\"Captura de pantalla 2016-05-14 a las 10.54.22.png\"   \/><\/div>\n<div class=\"post-limited-image\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/5a98cd16091cb2e2c16a9da9c4dfebf2.jpg\" \/><\/div>\n<div class=\"post-limited-image\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/5c82b711a540b2e4f890da52d9512988.jpg#038;blog=105581831&#038;%23038;post=125&#038;%23038;subd=lilihecblog&#038;%23038;ref=&#038;%23038;feed=1\" width=\"1\" height=\"1\" \/><\/div>\n<p><!--more--> two fibonacci numbers.<\/p>\n<p>\/\/CODE:<\/p>\n<p>\/\/ Ever Olivares<br \/>\n#include &lt;iostream&gt;<br \/>\nusing namespace std;<\/p>\n<p>long fibonacci(long n){<br \/>\nlong i=0,a=1,b=1,c=0;<br \/>\nif (n&lt;2){<br \/>\nreturn n;<br \/>\n}<br \/>\nif (n==2){<br \/>\nreturn 1;<br \/>\n}<br \/>\nwhile(i&lt;n-2)<\/p>\n<p>{<br \/>\nc=a+b;<br \/>\na=b; b=c;<br \/>\ni++;}<br \/>\nreturn c;<br \/>\n}<br \/>\nint main(){<br \/>\nlong n;<br \/>\ncout&lt;&lt; \u201cType the number \u201d &lt;&lt; endl;<br \/>\ncin &gt;&gt; n;<br \/>\ncout &lt;&lt; \u201cThe Fibonacci \u201d &lt;&lt; n &lt;&lt; \u201d position of the serie is: \u201d &lt;&lt; endl;<br \/>\ncout&lt;&lt;fibonacci(n)&lt;&lt;endl;<br \/>\nreturn 0;<br \/>\n}<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-137\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/14c9d35f42062f89d5904c63c27d2e32.jpg\" alt=\"Captura de pantalla 2016-05-14 a las 10.53.33.png\"   \/><\/p>\n<p>QUESTION 4:<\/p>\n<p>Write a function called isPalindrome which receives a string \u201cx\u201d and returns true if the string x is a palindrome, otherwise false.<\/p>\n<p>\/\/CODE:<\/p>\n<p>\/\/ Ever Oliavres<br \/>\n#include &lt;iostream&gt;<br \/>\n#include &lt;iomanip&gt;<br \/>\n#include &lt;string&gt;<\/p>\n<p>using namespace std;<\/p>\n<p>string word, fin;<\/p>\n<p>string is_palindrome(string word)<\/p>\n<p>{<br \/>\nstring backwards;<br \/>\ncout &lt;&lt; \u201cType a word: n\u201d;<br \/>\ncin &gt;&gt; word;<\/p>\n<p>int large = word.length();<br \/>\nfor (int x = large \u2013 1; x &gt;= 0; x\u2013)<\/p>\n<p>{<br \/>\nbackwards += word[x];<br \/>\n}<\/p>\n<p>if (backwards == word)<br \/>\n{<br \/>\nfin = \u201cYour word is a palindrome\u201d;<br \/>\n}<\/p>\n<p>else<br \/>\nfin = \u201cYour word is not a palindrome\u201d;<br \/>\nreturn fin;<br \/>\n}<br \/>\nint main()<br \/>\n{<br \/>\ncout &lt;&lt; is_palindrome(fin);<br \/>\n}<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-140\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/bdc0787499c3bea18e5cb3ae19ff1ed2.jpg\" alt=\"Captura de pantalla 2016-05-14 a las 10.54.22.png\"   \/><\/p>\n<p>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/lilihecblog.wordpress.com\/125\/\"><img decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/5a98cd16091cb2e2c16a9da9c4dfebf2.jpg\" \/><\/a> <img loading=\"lazy\" decoding=\"async\" alt=\"\" border=\"0\" src=\"http:\/\/kenscourses.com\/tc101winter2016\/wp-content\/uploads\/2016\/05\/5c82b711a540b2e4f890da52d9512988.jpg#038;blog=105581831&#038;%23038;post=125&#038;%23038;subd=lilihecblog&#038;%23038;ref=&#038;%23038;feed=1\" width=\"1\" height=\"1\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Aqu\u00ed esta resuleto correctamente el examen de segundo parcial, y con las instrucciones de como realizarlo: QUESTION 1: Write a function called triangles which receives a single parameter (int) which represents the size of a triangle as explained below. The function should print a triangle using loops (for or while). The only characters printed here &hellip; <a href=\"https:\/\/kenscourses.com\/tc101winter2016\/2016\/05\/wsq13-2-parcial\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">WSQ13- 2 Parcial<\/span><\/a><\/p>\n","protected":false},"author":77,"featured_media":38552,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[45],"class_list":["post-38511","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogs","category-syndicated","tag-sin-categoria"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/38511","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\/77"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/comments?post=38511"}],"version-history":[{"count":2,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/38511\/revisions"}],"predecessor-version":[{"id":38562,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/posts\/38511\/revisions\/38562"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/media\/38552"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/media?parent=38511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/categories?post=38511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2016\/wp-json\/wp\/v2\/tags?post=38511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}