I have a function that returns a pointer and I am making it to compute factorial of a given number.
This is the skeleton code which I can't alter
#include<stdio.h>
#include<string.h>
//Read only region start
char* factorial (int input1)
{
//Read only region end
//Write code here
}
The code I wrote is :
I tries this code too
#include<stdio.h>
#include<string.h>
//Read only region start
char* factorial (int input1)
{
//Read only region end
//Write code here
char fact=1;
while(input1!=0)
{
fact = fact * input1;
input1--;
}
return fact;
}
The left side says the question and right side is the code I am writing. The error it throws is " Segmentation fault"
The program doesn't require main()
function cause its something the mettl is using at backend to call the function and evaluate the results.