1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
denis-greek [22]
3 years ago
15

. Write a recursive function names factorial to compute the factorial of the parameter. Also write the main function, where you

ask the user to input a non-negative integer number. Then call the function factorial and display the result.
Computers and Technology
1 answer:
r-ruslan [8.4K]3 years ago
4 0

Answer:

Following are the code in c language

#include <stdio.h> // header file

long int factorial(int n); // declaration of factorial function

int main() // main function

{

   int n; // variable declaration

   printf("Enter a positive integer: ");

   scanf("%d", &n); // input number

   while(n<0) // checking the condition if number is negative

{

    printf("please enter a positive number:");

    scanf("%d", &n);

}

   printf("Factorial of %d = %ld", n, factorial(n)); // calling  factorial function

   return 0;

}

long int factorial(int n1) // recursive definition of factorial

{

   if (n1 >= 1)

       return n1*factorial(n1-1);

   else

       return 1;

}

Explanation:

In this program, it ask for a positive number input. if the value enter by user is negative then it again ask for positive input i.e positive number. Then it calls the recursive function of factorial. the recursive function factorial calculate the factorial recursively. suppose user input 4 then it goes to the if  part of program i.e return n*factorial(n-1); that means return 4*factorial(3) again recursive function call itself .this process repeated until it meets the base condition.  when a base condition meets, it return factorial of the given number.

output

Enter a positive integer: 5

factorial of 5=120

Enter a positive integer: -8

please enter a positive number:4

factorial of 4=24

You might be interested in
Select the Navy Admiral who invented a high-level programming language FLOW-MATIC in 1953.
oee [108]

Answer:

Grace Hopper.

Explanation:

Grace Hopper was a US Naval Rear Admiral and an American computer scientist who was born on the 9th of December, 1906 in New York city, United States of America. She worked on the first commercial computer known as universal automatic computer (UNIVAC), after the second World War II.

In 1953 at the Remington Rand, Grace Hopper invented the first high-level programming language for UNIVAC 1 by using words and expressions.

Hence, Grace Hopper was the Navy Admiral who invented a high-level programming language FLOW-MATIC in 1953.

Additionally, FLOW-MATIC paved the way for the development of common business-oriented language (COBOL).

4 0
3 years ago
Tom teaches in a high school. He wishes to sort a spreadsheet containing students' marks in various subjects by descending order
cricket20 [7]

Answer:

Select the data to sort

Explanation:

4 0
3 years ago
IT professionals recognize that successful systems must be user-oriented, and users need to be involved, formally or informally,
bogdanovich [222]

Answer:

True is the correct answer for the above question.

Explanation:

  • The software is a collection of instruction which states the computer to how to do a specific work. The software developer only develops the software, but it is used by many users of the software who wants to do some specific task.
  • The developer creates a graphical event for users through which the user can use the software of the computer system for his personal use.
  • So the above line concludes that the software is for the user only. So the user interaction in software development is necessary which is also said by the question-statement. Hence the question statement is the true statement.
5 0
3 years ago
5. The shell of a document that may be used over and over in desktop publishing is called a
Blababa [14]
The answer is B) Template. 

Various templates are available in most all desktop publishing programs, from resume templates in Word to Income Statement templates in Excel. Templates are useful for skipping the general "setup" process of making a document, and allow you to focus more on filling the document with the relevant data and polishing it to your specific needs once most of the legwork is done. 
6 0
3 years ago
Read 2 more answers
Five programs are currently being run in a computer. Program 1 is using 10 GiB of RAM, program 2 is using 5 GiB of RAM, program
muminat

Virtual memory could be used to allow program 5 to access RAM without any of the data from the other four programs being lost because it is one that tend to allows the system to give all of the process its own memory space that is said to be  isolated from the other processes.

<h3>How is virtual memory used instead of RAM?</h3>

A system is known to make use of a virtual memory and this is one that tend to make use of a section of the hard drive to act like the RAM.

With the use of virtual memory, a system can be able to load bigger or a lot of programs running at the same time, and this is one that tends to hep one to work as if it has more space, without having to buy more RAM.

Therefore, Virtual memory could be used to allow program 5 to access RAM without any of the data from the other four programs being lost because it is one that tend to allows the system to give all of the process its own memory space that is said to be  isolated from the other processes.

Learn more about virtual memory from

brainly.com/question/13088640

#SPJ1

6 0
1 year ago
Other questions:
  • What can help you best learn about appearance, habitats and behaviors of birds in your area
    9·1 answer
  • Ng/ Computer Applications - Office 2016 - EL3520 A
    13·1 answer
  • The first query is computationally less expensive than the second query. (Assume no indexes exist on release_date.) Query 1: SEL
    11·1 answer
  • Declare a variable temperature and initialize it to 98.6. Instructor Notes: Note that "initialize" means "declare and assign a v
    5·1 answer
  • Mad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (a
    14·1 answer
  • Q: If a program is invoked with "python program.py -r input.dat output.dat", what are the elements of argv?
    10·1 answer
  • Strengths and weaknesses about esport
    10·1 answer
  • Help! Picture provided
    7·2 answers
  • A folder is a collection of related of data is true or false​
    10·2 answers
  • How long will the plant have been dead when 87.5 percent of its C-14 has become N-14?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!