I have finish a program and it can run smoothly on other platform like replit... But one I run it on vs code it shows the following error and it also have something weird happen when I run check 50 for it.
Error occurs when running check50 cs50/problems/2022/x/cash
:) cash.c exists
:) cash.c compiles
:( get_cents returns integer number of cents
expected "100", not "32662"
:) get_cents rejects negative input
:) get_cents rejects a non-numeric input of "foo"
:) calculate_quarters returns 2 when input is 50
:( calculate_quarters returns 1 when input is 42
expected "1", not "32638"
:) calculate_dimes returns 1 when input is 10
:( calculate_dimes returns 1 when input is 15
expected "1", not "32528"
:) calculate_dimes returns 7 when input is 73
:( calculate_nickels returns 1 when input is 5
expected "1", not "32559"
:( calculate_nickels returns 5 when input is 28
expected "5", not "32731"
:( calculate_pennies returns 4 when input is 4
expected "4", not "32588"
:) input of 41 cents yields output of 4 coins
:) input of 160 cents yields output of 7 coins
Error occurs when I run make cash
cash.c:13:1: error: non-void function does not return a value [-Werror,-Wreturn-type]
}
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 errors generated.
make: *** [<builtin>: cash] Error 1
My code is attached below
#include <stdio.h>
#include <cs50.h>
int x=0;
int amount=0;
int get_cents(){
do{
amount=get_int("Change owed:");
}while(amount<=0);
}
int calculate_quarters(){
while(amount>=25){
amount=amount-25;
x++;
}
}
int calculate_dimes(){
while(amount>=10 && amount<25){
amount=amount-10;
x++;
}
}
int calculate_nickels(){
while(amount>=5 && amount<10){
amount=amount-5;
x++;
}
}
int calculate_pennies(){
while(amount>=1 && amount<5){
amount=amount-1;
x++;
}}
int main()
{
get_cents();
do{
calculate_quarters();
calculate_dimes();
calculate_nickels();
calculate_pennies();
}while(amount>0);
printf("%d\n",x);
return 0;
}
Please help me, thanks a lot.