Blame view

lab2/factorial.c 233 Bytes
e1249c637   kmazouzi   add debug lab2
1
  #include <stdio.h>
e1249c637   kmazouzi   add debug lab2
2
3
  int main()
  {
29b151012   kmazouzi   MAJ after first lab
4
      int i, num, fact;
e1249c637   kmazouzi   add debug lab2
5
6
      printf ("Enter the number: ");
      scanf ("%d", &num );
29b151012   kmazouzi   MAJ after first lab
7
8
9
      fact=1;
      for (i=1; i<=num; i++)
          fact=fact*i;    
e1249c637   kmazouzi   add debug lab2
10

29b151012   kmazouzi   MAJ after first lab
11
12
      printf("The factorial of %d is %d
  ",num,fact);
e1249c637   kmazouzi   add debug lab2
13
  }