In: Computer Science
Write a C++ program to read a collective of integer numbers. I f the number is greater than zero and less than 15 then terminate the loop and find factorial of the number
#include<iostream> using namespace std; int main() { int n; long f = 1; cout<<"Enter a number between 0(exclusive) and 15(exclusive): "; cin>>n; while(n<=0 || n>=15){ cout<<"Invalid input"<<endl; cout<<"Enter a number between 0(exclusive) and 15(exclusive): "; cin>>n; } for(int i =1;i<=n;i++){ f = f * i; } cout<<"Factorial of "<<n<<" is "<<f<<endl; return 0; }