Question

6. (30 points: 10 + 10 + 10) Draw Flow chart to find factorial using recursive method. Write a program in C and Assembly lan
0 0
Add a comment Improve this question Transcribed image text
Answer #1

START READ N -NO N> 0 > YES ERROR FACT = 1 STOP N == 1 YES WRITE FACT STOP FACT=FACTEN N=N+1

CODE IN C

#include<stdio.h>

long factorial(int N)

{

long fact = 1;

if (N == 1)

return(1);

else

fact = N * factorial(N-1);

return fact;

}

int main()

{

int num;

long fact;

printf("Enter a number: ");

scanf("%d", &num);

fact = factorial(num);

printf("\nFactorial of %d is %ld", num, fact);

}

#include<stdio.h> AWNP > clang-7 -pthread -m -o main main 5 ./main Enter a number: 10 long factorial(int N) Factorial of 10 i

NOTE: As per Chegg policy I am allowed to answer specific number of questions (including sub-parts) on a single post. Kindly post the remaining questions separately and I will try to answer them. Sorry for the inconvenience caused.

Add a comment
Know the answer?
Add Answer to:
6. (30 points: 10 + 10 + 10) Draw 'Flow chart to find factorial using recursive...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • For each of the following questions, you are required to draw a flow chart diagram using...

    For each of the following questions, you are required to draw a flow chart diagram using the right notation that you have learnt regarding the flow chart symbols. Draw a flow chart that can be used to write a program that:(a). Will represent the logic of a program that allows the user to enter a value. The program divides the value by 2 and outputs the result. (b). Will represent the logic of a program that allows the user to...

  • ASSEMBLY LANGUAGE (Mars MIPS) Starting code: Factorial: #Factorial Recursive function subu $sp, $sp, 4 sw $ra,...

    ASSEMBLY LANGUAGE (Mars MIPS) Starting code: Factorial: #Factorial Recursive function subu $sp, $sp, 4 sw $ra, 4($sp) # save the return address on stack beqz $a0, terminate # test for termination subu $sp, $sp, 4 # do not terminate yet sw $a0, 4($sp) # save the parameter sub $a0, $a0, 1 # will call with a smaller argument jal Factorial # after the termination condition is reached these lines # will be executed lw $t0, 4($sp) # the argument I...

  • Using Java: 1. Recursive Multiplication Write a recursive function that accepts two arguments into the parameters...

    Using Java: 1. Recursive Multiplication Write a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times y. Remember, multiplication can be performed as repeated addition as follows: 5×6=6+6+6+6+6 2. Recursive findings Write a recursive boolean method named reFinding. The method should search an array for a specified value, and return true if the value is found in the array, or false if the value is not found in...

  • Using Java programming language Your assignment is to implement a recursive reverse sorting algorithm. It should...

    Using Java programming language Your assignment is to implement a recursive reverse sorting algorithm. It should meet the following requirements: 1. The program shall graphically prompt the user for a file. 2. The program shall read the selected file which will contain 1 integer per line. 3. The program shall sort the values it reads from the file from largest to smallest. 4. The program shall write the values to an output file from largest to smallest in the same...

  • The language has to be in C program 1. (a) rite a function, int factorial (int...

    The language has to be in C program 1. (a) rite a function, int factorial (int n), which returns n (the factorial of n, i e. 1 x2 x3 x...xn.) (b) Using int factorial (int n) above, write a program to compute 2. We want to find one of the roots of a cubic equation given by which is between 0 and 1 by an iterative method. Modify the equation above to 1 x Start with an appropriate initial value...

  • 6 (10 points Remember the recursive Searching algorithm Binary Search. Write a recursive method to search...

    6 (10 points Remember the recursive Searching algorithm Binary Search. Write a recursive method to search for a target character in the array and return the index location if found or -1 if it is not found. 7 a5 points 17 points cach) Write the code to create a GUI based class Temperature Converter which inherits from JFrame and implements the ActionListerner interface. public static int binary Search(char target, char( theValues, int firstIndex, int lastindex) Example: Clicked "F to C"...

  • Write a C++ function to find factorial of an integer number N >0. Using the factorial...

    Write a C++ function to find factorial of an integer number N >0. Using the factorial function print the factorial of two inputs as shown below: Sample input: 1 4 Expected output: 1 24

  • 1) Draw a flow chart to count and print from 1 to 10. 2) Repeat using...

    1) Draw a flow chart to count and print from 1 to 10. 2) Repeat using a loop approach.

  • c++ page 2 ]. Write a C++ program that uses a recursive function to compute factorial...

    c++ page 2 ]. Write a C++ program that uses a recursive function to compute factorial (n!) Include comments in your code. dawoe llustrate with a ]. [extra credit] What are function or class "templates" in C++ ? ] Provide (short!) C++ code fragments which demonstrate how to write and re files. your code fragment should include preprocessor directive(s), all needed I/O declarations, and illustrative code for writing and reading data.eb ert benistno geami 10]. Write C++ code to sort...

  • MASM Assembly Language x86 Processor. Must use windows32 framework Write a non-recursive algorithm to find the...

    MASM Assembly Language x86 Processor. Must use windows32 framework Write a non-recursive algorithm to find the greatest common divisor of two positive numbers. . • Your program should read the two positive integers using dialog boxes. If they are not positive, a message box should be displayed with an appropriate message. • Your program needs to have a procedure that takes two positive integers as parameters. • You need to follow cdecl protocol for parameter passing. • Display the valid...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT