Is there an easy way to convert programs into modular? I just realised my code has to be in modular and have no clue how to convert my code easily
Code:
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <ctype.h>
int main()
{
int fifty, twenty, ten, five, result;
char option;
printf("This program will calculate change\n");
printf("Please input the number of cents between 5 - 95\n");
printf("Input must be in mulitples of 5\n");
printf("\n");
do
{
printf("Do you wish to continue? (Y/N): \n");
option = getch();
option = toupper (option);
}
while (!((option=='Y') || (option=='N')));
printf("%c\n",option);
if (option=='Y')
{
while (1)
{
printf("\nEnter Customers Change:\n");
scanf("%d", &result);
if ((result<0) || (result>95) || (result%5>0))
printf("Invalid Input!\n");
else{
fifty = result / 50;
result %= 50;
twenty = result / 20;
result %= 20;
ten = result / 10;
result %= 10;
five = result / 5;
result %= 5;
printf("The Correct Change =\n", result);
if (fifty > 1)
printf("%d Fifty cent piece's.\n", fifty);
if (fifty == 1)
printf("%d Fifty cent piece.\n", fifty);
if (twenty > 1)
printf("%d Twenty cent piece's.\n", twenty);
if (twenty == 1)
printf("%d Twenty cent piece.\n", twenty);
if (ten > 1)
printf("%d Ten cent piece's\n", ten);
if (ten == 1)
printf("%d Ten cent piece.\n", ten);
if (five > 1)
printf("%d Five cent piece's\n", five);
if (five == 1)
printf("%d Five cent piece.\n", five);
}
}
}
return(0);
}
any help would be cool