Question: 1) problem 1: The factorial of a nonnegative integer n is written n! (prononunced n factorial) and is defined as follows: N!=nx(n-1)x(n-2)x...x 1 (for values

1)

problem 1: The factorial of a nonnegative integer n is written n! (prononunced n factorial) and is defined as follows: N!=nx(n-1)x(n-2)x...x 1 (for values of n greater than or equal to 1) and n!=1(for n=0). For example, 5!=5x4x3x2x1, which is 120.

Write a program that reads a nonnegative integer from keyboard and use the for-loops to

Computes and prints its factorial if the number input is smaller than 3

Computes and prints the square of factorial value for the input number if the input number is larger or equal to 3. For example, if you input 6, the output should be 720*720=51,840.

Show the result for both cases.

NOTE: you must use one main function to realize the both cases, instead of two separated main.

2)

Problem 2: Develope a structured C program to

1)enters 3 numbers from the keyboard;

2) call function Max by value to find the maximum of the three numbers and print it on screen;

3)call function Min by value to find the minimum of the three numbers and print it on the screen;

4)calculate the difference between the maximum and minimum;

5)print the difference on screen if the difference >=8; but print on screen The difference between the maximum and the minimum is less than 8! if the difference

Max function takes 3 numbers from the main program, compares and returns the maximum.

Min function takes 3 numbers from the main program, compares and returns the minimum.

3)

Problem 3: Define two arrays x={3,5,7,9,11,13,15} and f={2,4,6,8,10,12,16}, each of size 7.

Use call-by-reference (that is, use pointer) to pass the array to a function, named summation.

In main: define arrays, print the arrays, pass the arrays to the function and print the summation result on screen

In function summation: take arrays from main and sum the arrays using the formula below:

1) problem 1: The factorial of a nonnegative integer n is written

NOTE: you must use call-by-reference (the pointer) to call functions, as required; otherwise, no credits will be given.

xi + fi

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!