From 594a08f029e675bbb535fc65197e8c5c90784533 Mon Sep 17 00:00:00 2001 From: Komal Gupta Date: Tue, 25 May 2021 12:35:23 +0530 Subject: [PATCH 1/2] Create Calculator.cpp Added full fledged calculator program --- Calculator.cpp | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Calculator.cpp diff --git a/Calculator.cpp b/Calculator.cpp new file mode 100644 index 0000000..0a2b7a6 --- /dev/null +++ b/Calculator.cpp @@ -0,0 +1,73 @@ + +#include +void main() +{ + char ch,f='y'; + int n,a,b,d,c=0,e=1; + + do + { + printf("Enter the operation to be perform(+,-,*,/,%)"); + fflush(stdin); + scanf("%c",&ch); + switch(ch) + { + case'+': + printf("\n How many numbers you want to add"); + scanf("%d",&n); + for(a=1;a<=n;a++) + { + printf("Enter the number"); + scanf("%d",&b); + c+=b; + } + printf("\n sum is:%d \n",c); + break; + case'-': + printf("Enter the number from which you want to sub"); + scanf("%d",&b); + printf("\n How many numbers you want to sub from %d-",b); + scanf("%d",&n); + + for(a=1;a<=n;a++) + { + printf("\n Enter the numbers to sub from %d-",b); + scanf("%d",&d); + b-=d; + } + printf("\n difference is:%d \n",b); + break; + case'*': + printf("\n How many numbers you want to multiply"); + scanf("%d",&n); + for(a=1;a<=n;a++) + { + printf("Enter the number"); + scanf("%d",&b); + e*=b; + } + printf("\n Ans is:%d \n",e); + break; + case'/': + printf("Enter the number which you want to divide"); + scanf("%d",&b); + printf("Enter the number by which you want to divide %d-",b); + scanf("%d",&a); + n=b/a; + printf("\n Ans is:%d \n",n); + break; + case'%': + printf("Enter the number of which you want percentage"); + scanf("%d",&b); + printf("how many percent you want to calculate "); + scanf("%d",&a); + e=b*a/100; + printf(" percentage amount is:%d \n",e); + break; + + } + + printf("Do you want to continue(y,n)"); + scanf("%d",&f); + fflush(stdin);}while(f!='n'); +} From 8b303cd215869715f2109721b0dec6a073fc32e3 Mon Sep 17 00:00:00 2001 From: Komal Gupta Date: Tue, 25 May 2021 13:39:04 +0530 Subject: [PATCH 2/2] Rename Calculator.cpp to Calculator.c --- Calculator.cpp => Calculator.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Calculator.cpp => Calculator.c (100%) diff --git a/Calculator.cpp b/Calculator.c similarity index 100% rename from Calculator.cpp rename to Calculator.c