Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assignment: Do one of the following: 1. (100 PTS) Place the first 40 Fibonacci numbers in an array, and then print them out in a
Assignment: Do one of the following: 1. (100 PTS) Place the first 40 Fibonacci numbers in an array, and then print them out in a column 1. Go to Codeblocks and open a new C or C++ program in a folder called Lastname-Program 2 2. Compile it, and ensure that it works 3. Now, create a new Fortran application. Give it an appropriate name (lastname-P2, something like this) and click the "next" button 4. You will now need to select the GNU Fortran compiler, then select the Finish button 5 If you get an error message that it is not finding the compiler you will need to do the following: Go to Settings->Compiler and select GNU Fortran Compiler - Select the Toolchain executables tab Go to the Compiler's Installation Directory space and select the (...) Select C: Program Files CodeBlocks MinGW bin - The top three files of "Program Files" space should all be gfortran.exe Select OK - If it reverts back to GCC you may need to make the Fortran Compiler the default 6. Click on the main 95 file in the left column of the IDE under "Workspace 7. You may simplify the default program to this: 7 2. (105 PTS) Write a program that prints a one-month calendar. The user specifies the number of days in the month and the day of the week on which the month begins: Enter number of days in month: 31 Enter starting day of the week (1=Sun, 7-Sat): 3 1 2 3 4 5 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Hint: This program isn't as hard as it looks. The most important part is a for statement that uses a variable i to count from 1 ton, where n is the number of days in the month, printing each value of i. Inside the loop, an if statement tests whether i is the last day in a week; if so, it prints a new-line character. For option 2 you will need to use the modulus function, which is called like this: program main print, "Hello World!" end 8. Compile this program and convince yourself that it works. 9. See assignment options on the reverse: ! Computes the remainder of the division of A by P. MOD(A,P) 3._ 110 PTS) Print the first n prime numbers using the Sieve of Eratosthenes. You do not need to write it in a function, it can be in the main part of your program. ALGORITHM Sieve(n) I/Implements the sieve of Eratosthenes I/Input: A positive integer n > 1 I/Output: Array L of all prime numbers less than or equal ton for p +2 ton do Alplp for p 2 to do if Alp0 Ilp hasn't been eliminated on previous passes pop whilej s ndo Al-0 mark element as eliminated jj+P Il copy the remaining elements of A to array L of the primes for p 2 to n do if Ap 40 20-A[PI ii+1 return
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started