adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

program in c calculate the factorial of a given number using pointer to function

program in c calculate the factorial of a given number using pointer to function.



#include<stdio.h>
#include<conio.h>
  void (*FunPtr)(int );
  void Fact(int n)
  {
      int f=1,i;
      for(i=1;i<=n;i++)
      {
          f=f*i;
      }
      printf("Factorial =%d",f);
  }
  int main()
   {
       int a;
       printf("Enter a number:-");
       scanf("%d",&a);
       FunPtr = &Fact;
       FunPtr(a);
       getch();
       return 0;
   }

Output:-


Post a Comment

0 Comments