From d1bfe7479599f1bbebadd70e752e883fcfd103ff Mon Sep 17 00:00:00 2001 From: CHAITANYA BHATIA <117209756+chaitaanyaaaa@users.noreply.github.com> Date: Tue, 1 Nov 2022 23:47:02 +0530 Subject: [PATCH] =?UTF-8?q?Update=20Exercise=201=20-=20L=C3=A9o.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Exercise 1 - L\303\251o.c" | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git "a/2021 Feb Lab Sheets/Lab Sheet 11/Lab Sheet 11 - L\303\251o/Exercise 1 - L\303\251o.c" "b/2021 Feb Lab Sheets/Lab Sheet 11/Lab Sheet 11 - L\303\251o/Exercise 1 - L\303\251o.c" index b7b97e1..f7c5ce1 100644 --- "a/2021 Feb Lab Sheets/Lab Sheet 11/Lab Sheet 11 - L\303\251o/Exercise 1 - L\303\251o.c" +++ "b/2021 Feb Lab Sheets/Lab Sheet 11/Lab Sheet 11 - L\303\251o/Exercise 1 - L\303\251o.c" @@ -1,19 +1,16 @@ #include -int main() +int fact(int n) { - int x,facto=1; - - printf("Enter Number: "); - scanf("%d",&x); - - printf("Factorial of %d is: ",x); - - while(x!=0) - { - facto *= x; - x--; - } - - printf("%d",facto); + if(n>=1) + return 1; + else + return n*fact(n-1); +} +void main() +{ + printf("ENTER ANY NUMBER"); +scanf("%d",&num); + prinf("%d",fact(num)); + getch(); }