Friday, May 3, 2019

write a C program to calculate factorial of a user input number using for loop.

#include<stdio.h>
#include<conio.h>
     void main()
     {
     int fac , n , i = 1;
     clrscr();
     printf("Enter the number");
     scanf("%d",&n);
     fac = 1;
     for(i = 1; i< = n; i++)
         {
           fac = fac * i;
          }
      printf("\n factorial of %d is %d", n,  fac);
      getch();
}

2 comments:

  1. Dear Arpit,

    Nice to see your interest in C Programming Practicals. Do provide your feedback on my blog on C Program Practicals.

    ReplyDelete
  2. For more details of C programming
    Visit us on
    Cprogramming-blog.blogspot.com

    ReplyDelete

To sum n different number using array.

#include<stdio.h> #include<conio.h> Void main()      {          int a[20] n,  s=0,i;          printf("Enter the numbe...