Hello i keep getting this error?? im not user where i went wrong? it just keep added more? thank you
//
// main.c
// Assignment1
//
// Created by Hassan omer on 15/10/21.
//
#include <stdio.h>
# include <stdlib.h>
int input();
int multiples();
int coins();
void display_change();
int cent50 = 0;
int cent20 = 0;
int cent10 = 0;
int cent05 = 0;
int main() {
char choice = (char)0;
int num;
do {
num = input();
multiples(num);
coins(num);
display_change();
int cent50 = 0;
int cent20 = 0;
int cent10 = 0;
int cent05 = 0;
}while(choice != 'q');
return 0;
}
int input(int num)
{
printf("enter 5-95 number\n");
scanf("%d",&num);
return num;
}
int multiples(int num)
{
int sum5 =0;
if (num %5 != 0 ||num<=4|| num >=96) {
printf("invaild input %d\n",num);
exit(0);
}
return sum5;
}
int coins(int sum5){
if (sum5 > 0)
{
while (sum5 >= 50){
sum5 -= 50;
cent50++;
}
while (sum5 >=20){
sum5 -= 20;
cent20++;
}
while (sum5 >= 10){
sum5 -=10;
cent10++;
}
while (sum5 >= 05){
sum5 -= 05;
cent05++;
}
}
return (sum5);
}
void display_change(int sum5)
{
if (cent50)
printf("cent50 : %d\n",cent50);
if(cent20)
printf("cent20 : %d\n",cent20);
if(cent10)
printf("cent10 : %d\n",cent10);
if(cent05)
printf("cent05 : %d\n",cent05);
}
Hello i keep getting this error?? im not user where i went wrong? it just keep added more? thank you
Step by step
Solved in 2 steps with 1 images