WSQ13 – Exam 2nd Partial


El propósito de este post, es publicar los enlaces de los códigos realizados en el examen del segundo parcial de esta materia.

Programa 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 are ‘T’ 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.

Link GitHub: Exam 2 – Prog 1

Programa 2

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 a b So, superpower(3,4) would return 81. long superpower(long a, long b){


Link GitHub: Exam 2 – Prog 2

Programa 3

NOTE: for full 5 points, use a loop (not recursion). Write a function called fibonacci which receives a long “n” 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………… So, 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 1. All others are the sum of the previous two fibonacci numbers.

Link GitHub: Exam 2 – Prog 3

Programa 4

Write a function called isPalindrome which receives a string “x” and returns true if the string x is a palindrome, otherwise false.

Link GitHub: Exam 2 – Prog 4

CC BY-SA 4.0 WSQ13 – Exam 2nd Partial by danamaro is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.