Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
4bbd676861 | |||
753015e21e | |||
68cc943dbf | |||
43e71b4b0a | |||
dd9538ff4c |
22
Source1.cpp
22
Source1.cpp
@ -0,0 +1,22 @@
|
|||||||
|
#include <iostream>
|
||||||
|
int factorial(int n) {
|
||||||
|
return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
|
||||||
|
}
|
||||||
|
int main() {
|
||||||
|
int num;
|
||||||
|
std::cout << "Enter a number: ";
|
||||||
|
std::cin >> num;
|
||||||
|
std::cout << "Factorial: " << factorial(num) << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#include <iostream>
|
||||||
|
int sum(int a, int b) {
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
|
int main() {
|
||||||
|
int x, y;
|
||||||
|
std::cout << "Enter two numbers: ";
|
||||||
|
std::cin >> x >> y;
|
||||||
|
std::cout << "Sum: " << sum(x, y) << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user