0
Shouldnt this ask for a second imput if the number is negative
#include <iostream> using namespace std; int factorial(int n) { if (n<=1) { return 1; } else { return n * factorial(n-1); } } int main() { int x; cin >> x; while(x<=-1){ cout << "try again"; cin >> x;} cout << factorial(x); }
5 odpowiedzi
+ 15
The code runs fine, just tried it out.
+ 4
If you're running it on codeplayground, you can only get one input at start of run-time. Just the way code playground is designed.
+ 3
AIDE-IDE might be ok for mobile. Never actually tried it, just an assumption on number of downloads.
0
kk thanks
0
whats a app or online program for mobile devices thag will allow me to do multiple inputs and maybe even small c++ games like snake or pacman or older games just to get the theory down