Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write pseudocode segments in the style of Cheney and Kincaid to solve the follow

ID: 3870571 • Letter: W

Question

Write pseudocode segments in the style of Cheney and Kincaid to solve the following problems:

a) Assuming an integer variable n has already been initialized, calculate n factorial in another integer

variable f, and output both n and f. You may assume that the value initialized in n is nonnegative, but

account for the case where n=0.

b) Given an initialized array of 100 real variables named x, find the minimum and maximum of the

values in the array, and output these two extreme values.

c) Assuming an integer variable n has already been initialized, output the first n integers in the Fibonacci

sequence. (See http://en.wikipedia.org/wiki/Fibonacci_number). You may assume that the value

initialized in n is greater than 2

Explanation / Answer

For Computing factorial

program factorial

integer i,f <-- 1,n

input n

if n==0 then

f <-- 1

else

for i=1 to n do

f <-- f*i

output n,f

end program factorial

-------------------------------

For finding maximum and minimum

program max_min

integer arr[100],i,max <-- 0, min <-- arr[1]

for i=1 to 100 do

if arr[i] > max then max <-- arr[i]

if arr[i] < min then min <-- arr[i]

output max

output min

end program max_min

-------------------------------

For printing Fibonacci series

program fibonacci

integer a <-- 0, b <--1,c,n,i <-- 3

input n

output a

output b

for i <-- 3 to n do

c <-- [a+b]

output c

a <-- b

b <-- c

end program fibonacci

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote