0

is there another code to print the factorial of the numbers from 1 to ten

#include <iostream> using namespace std; int main() { int number , fact=1; for(number=1;number<=10;number++) { for(int i=1;i<=number;i++) fact*=i; cout<<"the factorial of "<< number <<" is "<<fact<<"\n"; fact=1; } return 0; }

22nd Aug 2019, 10:48 AM
Mahmoud Hamed
Mahmoud Hamed - avatar
2 Respuestas
+ 1
Recusive and iterative programm code can always be converted to each other :) so there are many ways to do this 😋 and you could shorten your code :)
22nd Aug 2019, 11:16 AM
Tom Hammerbacher
Tom Hammerbacher - avatar
+ 2
U can use recursive function to do the same...
22nd Aug 2019, 10:56 AM
Kuri
Kuri - avatar