Skip to main content

Factorial program in c

Factorial program in c using recursion



#include <stdio.h>
#include <stdlib.h>
 #define b 10

int main()
{
const int a=0;
int facto;

if(a<=0)
{
printf("error a value should be more then 0");
}
else
{
facto = factorial(a);



    printf("factoria of %d is  %d\n",a,facto);
 }
    return 0;
}

int factorial(int k)
{



if(k<=1)
{
return 1;
}

k=k * factorial(k-1);

return k;

}

Comments

Popular posts from this blog

CAN INTERVIEW QUESTIONS

Qualifiers and Modifier in C

RTOS Real time operating system interview questions

CAN INTERVIEW QUESTIONS 2

What is UDS protocol

Memory mapping in c

TOP IOT PLATFORMS