From f68cc739f81fb3a618e48e5d536c7f5a5418264a Mon Sep 17 00:00:00 2001 From: Rohandutt <56020065+Rohandutt@users.noreply.github.com> Date: Tue, 1 Oct 2019 14:01:15 +0530 Subject: [PATCH] Added factorial c code and remove hello world code --- factorial.c | 13 +++++++++++++ hello_world.cpp | 7 ------- 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 factorial.c delete mode 100644 hello_world.cpp diff --git a/factorial.c b/factorial.c new file mode 100644 index 0000000..fca3de8 --- /dev/null +++ b/factorial.c @@ -0,0 +1,13 @@ +#include +int main() +{ +int i,n; +long f; +printf("\nEnter a number whose factorial is to be calculated:"); +scanf("%d",&n); +for(i=n;i>=1;i--) +{f*=i;} +printf("\nThe factorial is %ld",f); +return 0; +} + diff --git a/hello_world.cpp b/hello_world.cpp deleted file mode 100644 index 91bd83b..0000000 --- a/hello_world.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include