Guest User

Untitled

a guest
Jan 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. //------------------------------------------------------------------------------
  2. // hw2.c
  3. //
  4. // This program calculates the
  5. // factorial of every second number
  6. // from my Matrikelnumber
  7. //
  8. // Group: Group 1, study assistant Severin-Holzgraf
  9. //
  10. // Authors: Roland Urbano 1130357
  11. //------------------------------------------------------------------------------
  12. //
  13.  
  14. #include <stdio.h>
  15.  
  16. //------------------------------------------------------------------------------
  17. //
  18. // This is the main function where the factorial is calculated
  19. //
  20. int main ()
  21. {
  22. int summ = 20; //summ of matr_number
  23. double modulo = summ % 2;
  24. double counter = 0;
  25. double max_wert = 0;
  26. double factorial = 1; //Variable zum speichern der Fakultät
  27.  
  28. while (modulo != 1)
  29. {
  30. while ( counter <= max_wert )
  31. {
  32. factorial = factorial * counter;
  33. counter++;
  34. }
  35.  
  36. printf("%e\n", factorial);
  37.  
  38. max_wert = max_wert + 2;
  39.  
  40. while ( counter == summ)
  41. {
  42. modulo = 1;
  43. }
  44. }
  45.  
  46. return 0;
  47. }
Add Comment
Please, Sign In to add comment