From c049cc5c22a63cbe4040ff89f68ccf1c2b7a0702 Mon Sep 17 00:00:00 2001 From: Tushar Date: Tue, 16 May 2023 15:56:04 +0530 Subject: [PATCH] we handle negative integers --- factorial.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/factorial.cpp b/factorial.cpp index b27b86a..2c249de 100644 --- a/factorial.cpp +++ b/factorial.cpp @@ -7,6 +7,10 @@ int main() { cout << "Enter a positive integer: "; cin >> n; + if(n < 0){ + cout << "you can't enter negative integer"; + return -1; + } for(int i = 1; i <= n; ++i) { factorial *= i; }