+ 5
Functions are generally used to reduce redundancy (repetitions) in code. int factorial (int num) { if (num == 1) return 1; else return num * fact(num - 1); } And, inside the main() cout << factorial(5); Output will be 5! = 120.
12th Apr 2017, 10:57 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar