Question: Your first lab will be similar to the examples discussed in class, covering programming concepts in loop, function, and recursion. It includes the following tasks:
Your first lab will be similar to the examples discussed in class, covering programming concepts in loop, function, and recursion. It includes the following tasks: Using C/C++, write loop(s) to control and output a star pattern as follows: giving a integer N (use cm to assign N), first, you need to print a triangle with N rows, the star number in each row equals the row number (e.g. the 1^st row has 1 star, the N^th row has N stars). Then output a reverse triangle with (N-1) row, the first row of the reverse triangle has (N-1) stars, and the last row of the reverse triangle has 1 star. All stars are center aligned, and the pattern is in a diamond shape. E.g. when N is 3, you will print the following star pattern In main(), declare a variable N, input an integer (positive and less than 30) from standard input (keyboard); based on the value of N, use a loop to calculate the N^th Fibonacci number and print the result. Define a recursive function to calculate Fibonacci numbers In main(), assign N with an integer (positive and less than 20) from standard input. Based on the value of N, call the recursive function and output the N^th Fibonacci number: Fibonnacci(N) = Fibonacci(N - 1) + Fibonacci(N - 2) The following specifications will be expected for each of your projects in this class: An empty project file must be created first, and then you will create new source file and header files. Add comments at the beginning of the program, and add description for each function, loop, etc
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
