Lab 01 C loops


Category: You will Instantly receive a download link for .zip solution file upon Payment


5/5 - (2 votes)

Write a program that asks for a positive integer n and builds a triangle like so:
What is n? 4
What about writing a function and calling it multiple times? Can you do this with nested for loops?
Hypotenuse of the triangle
Given the previous problem, you can now build a right triangle. Assuming the legs of the triangle are the
same, find the hypotenuse. Use this page web page to only print out two digits of precision (search for
Recall that the factorial of a number n, n! is n * n-1 * n-2 . . . * 2 * 1. Write a program (using long and
not int) that asks for a positive integer and computes its factorial. Run it on larger and larger numbers.
Does it take a long time? Is there any way to speed this computation up? (Hint: try saving the result of the
computations in memory)