pages

Wednesday, 5 May 2021

c-program to calculate factorial of a number by using pointer | c-programming

program to calculate the factorial of the any number by using pointer 

In this program , we will now calculate the factorial of the number by taking input from the user by using  pointer in  c-programming


#include<stdio.h>
#include<conio.h>
int factorial(int *, int*);
void main()
{
         int fact,num;
         printf("enter the number:-");
         scanf("%d",&num);
         factorial(&num,&fact);
         printf("\n the factorial of the %d is %d",num,fact);
         getch();
}
int factorial(int *n,int *f)
{
         int i;
         *f=1;
         for(i=1;i<=*n;i++)
                  *f=*f*(i);
                  return(*f);
}

output:-



For more c-programming:-






















No comments:

Post a Comment