Write a C program that takes a command line argument of a number that you need to calculate the factorial value of. The program must use a recursive function to calculate the result and then print the result to standard output. The program must perform the following functionality: 1. Create and save a new C program called factorial.c 2. Correct type definition for recursive function. 3. Correct type definition for main function to process input arguments. 4. Correct type definitions for variables. 5. Ensure command line arguments to read in the input number to calculate the factorial is used. 6. Test if the correct number of input arguments are entered when the program is called and print an error message if insufficient arguments are entered. 7. Convert the string to a number and test the entered number is not a negative number and print an error message if negative. 8. Convert the entered argument to the correct data type format and call a recursive function called to recursively calculate the factorial of the number. Ensure you use the correct data types. 9. Exit the recursive function and print the result in the main calling function

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please make use of argv and argc to allow the code to run through command line arguments. Thanks

Write a C program that takes a command line argument of a number that you need to calculate the factorial
value of. The program must use a recursive function to calculate the result and then print the result to
standard output. The program must perform the following functionality:
1. Create and save a new C program called factorial.c
2. Correct type definition for recursive function.
3. Correct type definition for main function to process input arguments.
4. Correct type definitions for variables.
5. Ensure command line arguments to read in the input number to calculate the factorial is used.
6. Test if the correct number of input arguments are entered when the program is called and print an error
message if insufficient arguments are entered.
7. Convert the string to a number and test the entered number is not a negative number and print an error
message if negative.
8. Convert the entered argument to the correct data type format and call a recursive function called to
recursively calculate the factorial of the number. Ensure you use the correct data types.
9. Exit the recursive function and print the result in the main calling function
Transcribed Image Text:Write a C program that takes a command line argument of a number that you need to calculate the factorial value of. The program must use a recursive function to calculate the result and then print the result to standard output. The program must perform the following functionality: 1. Create and save a new C program called factorial.c 2. Correct type definition for recursive function. 3. Correct type definition for main function to process input arguments. 4. Correct type definitions for variables. 5. Ensure command line arguments to read in the input number to calculate the factorial is used. 6. Test if the correct number of input arguments are entered when the program is called and print an error message if insufficient arguments are entered. 7. Convert the string to a number and test the entered number is not a negative number and print an error message if negative. 8. Convert the entered argument to the correct data type format and call a recursive function called to recursively calculate the factorial of the number. Ensure you use the correct data types. 9. Exit the recursive function and print the result in the main calling function
Expert Solution
steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY