I'm brand new to C++ ,I've written following code for finding a number's factorial,Can you please let me know how to write it more elegantly ?
#include <iostream>
using namespace std ;
main ()
{
int num = 0 ; // declaring variables
double result = 1 ;
long int i = 1;
cout << " Please Enter a Number : " ; // taking input from user
cin >> num ;
while ( i <= num ) // factorial
{
result *= i ;
i++ ;
}
cout << num << " ! = " << result ;
cin.get () ;
}