Professional Documents
Culture Documents
Loops
Loops
h>
2. #include <conio.h>
3.
4. void main()
5. {
6. int number, i = 1, factorial = 1;
7.
8. cout << "Enter a positive integer: ";
9. cin >> number;
10.
11. while ( i <= number)
12. {
13. factorial = factorial * i;
14. i++;
15. }
16.
17. cout<<"Factorial of "<< number <<" = "<< factorial;
18. getch();
19. }
Output
Enter a positive integer: 4
Factorial of 4 = 24