1. Write a C++ program that accepts a positive number form the user then calculates and displays the factorial value of that number.
2. Update the code not to accept negative numbers.
3. Update the code to have an indefinite while loop that keeps requesting other positive numbers to display their factorial results too, until the user press zero to exit the program.
Exercise #3 1. write a C++ program that accepts a positive number form the user then calculates and displays the factorial value of that number. 2. Update the code not to accept negative numbers. 3. date the code to have an indefinite while loop that keeps requesting other positive numbers to display their factorial results too, until the user press zero to exit the program. Your results must be displayed exactly as shown below: Program to find the factorial of a positive number Enter a positive number: 5 Factorial of 5 is: 120 Do you want to continue? (If No press zero to exit 2 Enter a positive number: 3 Factorial of 3 is: 6 Do you want to continue? (If No press zero to exit) o Thank You.
#include
int main() { int n,k,i; unsigned long long factorial = 1; fact: printf(\"Enter an integer: \"); scanf(\"%d\",&n); // show error if the user enters a negative integer if (n < 0) printf(\"Error! Factorial of a negative number doesn\'t exist.\"); else { for(i=1; i<=n; ++i) { factorial *= i; // factorial = factorial*i; } printf(\"Factorial of %d = %llu\", n, factorial); } printf(\"do you want to continue?(if no press zero to exit)\"); scanf(\"%d\",&k); if(k==0) exit; else goto fact; }