11. Write a program that uses a function called Factorial which takes only one i
ID: 3592498 • Letter: 1
Question
11. Write a program that uses a function called Factorial which takes only one inputN (an integer) and computes and returns the answer as a double. The factorial is computed as 1 *2 3 . N (Use a loop inside the function to do this). Write the main that sends a suitable value for N and displays the value of the Factorial after calling the function. 12. Given the following program, answer the questions given below: #include using namespace std void Test(int a, int &b;, int c), int main int first, second, third first = 2; second = 3; third = 9; Test(first, second, third) coutExplanation / Answer
11)
#include<iostream>
using namespace std;
double factorial (int n)
{
fact=1;
for(int i=1;i<n;i++)
fact*=i;
return fact;
}
int main()
{
double fact = factorial(5);
cout<<fact;
}
12)
function prototype : void Test(int a ,int&b , int c);
value parameters : int a int c
reference parameters : int &b
function call : Test(first , second , third);
output:
first = 2
second = 7
third = 9
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.