From b179d4f0e67ded2d8bc21e6bab16a10ea26616d9 Mon Sep 17 00:00:00 2001 From: MEGHWANT SINGH <68533246+Meghwantsingh@users.noreply.github.com> Date: Fri, 8 Oct 2021 17:44:18 +0530 Subject: [PATCH 1/2] Create basicArithmeticCalculator.c basicArithmeticCalculator file is added in C folder https://github.com/Meghwantsingh/hacktoberfest2k21/new/feature-branch/C review it and thanks for telling If you get any issue pls tell and i have some issue with branch ..So check. --- .../basicArithmeticCalculator.c | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 C/basicArithmeticCalculator/basicArithmeticCalculator.c diff --git a/C/basicArithmeticCalculator/basicArithmeticCalculator.c b/C/basicArithmeticCalculator/basicArithmeticCalculator.c new file mode 100644 index 0000000..9f2cd09 --- /dev/null +++ b/C/basicArithmeticCalculator/basicArithmeticCalculator.c @@ -0,0 +1,37 @@ + /* + Author : Meghwant singh + Date : 08/oct/2021 + Description : basic arithmetic calculator + - * using C language + */ + // basic arithmetic calculator + - * / % + +#include + +int main() { + char op; + double first, second; + printf("Enter an operator (+, -, *, /): "); + scanf("%c", &op); + printf("Enter two operands: "); + scanf("%lf %lf", &first, &second); + + switch (op) { + case '+': + printf("%.1lf",first + second); + break; + case '-': + printf("%.1lf", first - second); + break; + case '*': + printf("%.1lf",first * second); + break; + case '/': + printf("%.1lf",first / second); + break; + // If operator doesn't match any case constant + default: + printf("operator is not correct"); + } + printf("\n"); + return 0; +} From a2fae9cd15a0acd1848fee5082bcaf56f0535151 Mon Sep 17 00:00:00 2001 From: MEGHWANT SINGH <68533246+Meghwantsingh@users.noreply.github.com> Date: Fri, 8 Oct 2021 17:54:44 +0530 Subject: [PATCH 2/2] Create basicArithmeticCalculator.c check. --- C/Language/C/basicArithmeticCalculator.c | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 C/Language/C/basicArithmeticCalculator.c diff --git a/C/Language/C/basicArithmeticCalculator.c b/C/Language/C/basicArithmeticCalculator.c new file mode 100644 index 0000000..49b63d5 --- /dev/null +++ b/C/Language/C/basicArithmeticCalculator.c @@ -0,0 +1,36 @@ +/* + Author : Meghwant singh + Date : 08/10/2021 + Description : Basic Arithmetic Calculator in C language . + */ + +#include + +int main() { + char op; + double first, second; + printf("Enter an operator (+, -, *, /): "); + scanf("%c", &op); + printf("Enter two operands: "); + scanf("%lf %lf", &first, &second); + + switch (op) { + case '+': + printf("%.1lf",first + second); + break; + case '-': + printf("%.1lf", first - second); + break; + case '*': + printf("%.1lf",first * second); + break; + case '/': + printf("%.1lf",first / second); + break; + // If operator doesn't match any case constant + default: + printf("operator is not correct"); + } + printf("\n"); + return 0; +}