Browse Source

refactoring: format the code by implementing new variables and important comments in displayMenuCalculator.c and displayMenuCalculator.h

remotes/origin/feature/display-menu-calculator
fdai7514 2 years ago
parent
commit
c4280af27c
  1. 17
      src/displayMenuCalculator.c
  2. 10
      src/displayMenuCalculator.h

17
src/displayMenuCalculator.c

@ -1,4 +1,9 @@
#include "displayMenuCalculator.h" #include "displayMenuCalculator.h"
// Note:
/* This Function may or may not be implemented in actual program, even if it is merged to the main branch.
If it is temporarily not included in the main Program, then this has a role in future Development of the Project */
int check() int check()
{ {
if(a == 1) if(a == 1)
@ -7,18 +12,20 @@ return 1;
} }
} }
void displayMenuCalculator(char x) void displayMenuCalculator(char x)
{ {
if(x == 'c') if(x == 'c')
{ {
if(check() == 1) if(check() == 1)
{ {
printf(" 1. Add\n");
printf(" 2. Subtract\n");
printf(" 3. Multiply\n");
printf(" 4. Divide\n");
printf(" 5. Factorial\n");
printf(" %d. Add\n", operation1);
printf(" %d. Subtract\n", operation2);
printf(" %d. Multiply\n", operation3);
printf(" %d. Divide\n", operation4);
printf(" %d. Factorial\n", operation5);
} }
} }
} }

10
src/displayMenuCalculator.h

@ -3,8 +3,14 @@
#include<stdio.h> #include<stdio.h>
#include<stdlib.h> #include<stdlib.h>
int check();
const int a = 1;
int check(); //int check() is helpful for indirectly testing void displayMenuCalculator()
const int a = 1; // Variable for indirectly testing void displayMenuCalculator()
void displayMenuCalculator(char x); void displayMenuCalculator(char x);
int operation1 = 1;
int operation2 = 2;
int operation3 = 3;
int operation4 = 4;
int operation5 = 5;
#endif // DISPLAYMENUCALCULATOR_H #endif // DISPLAYMENUCALCULATOR_H
Loading…
Cancel
Save