-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfactorial.cpp
More file actions
executable file
·31 lines (30 loc) · 819 Bytes
/
Copy pathfactorial.cpp
File metadata and controls
executable file
·31 lines (30 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <iomanip>
int main()
{
int value = 1;
int num1 = 1;
int factorial = 1;
std::cout << "Calculating a Factorial\n";
do
{
std::cout << "Enter a value between 1 and 10. (0 to quit): ";
std::cin >> value;
if (value >0 && value < 11)
{
for (num1=1 ; num1 <= value ; num1++)
factorial *= num1;
std::cout << "------------------\n" << std::endl;
std::cout << value << "! = " << factorial << std::endl << std::endl;
}
else if (value != 0)
{
std::cout << "The value is out of range.\n";
std::cout << "Please Re-enter a value between 1 and 10. (0 to quit): ";
std::cin >> value;
}
}
while (value!=0);
std::cout << "Goodbye!\n";
}
//lol mackintosh dekhega? na bhai jyada time ni hai. ok bas gaana lagane de :3