I got this error ( cash.c:69:7: error: function definition is not allowed here { ) while working for the cash problem of pset 1 of cs50. The point of this program is to get the change of a payment as input and the program tells you the least amount of coins needed to pay back the change
I checked the lines over and over again but the error doesn’t seem to apply. THE ERROR IS ON LINES 69, 78, 87, AND 96. I ALSO PUT COMMENTS LABELED “OVER HERE!!!” (THE ERROR APPEARS AT THE END OF THE CODE BTW) I DELETED THE UNNECESSARY PARTS OF THE CODE Here’s the code:
#include <stdio.h>
#include <cs50.h>
#include <math.h>
//Making computer remember functions
void Quarter();
void Dime();
void Nickel();
void Penny();
int main(void)
{
//variables
float input = get_float("Change owed: ");
float process = input;
int ncoin = 0;
bool done = false;
//the array for coins
float Coins[4];
//Quarter
Coins[0] = 0.25;
//Dime
Coins[1] = 0.10;
//Nickel
Coins[2] = 0.05;
//Penny
Coins[3] = 0.01;
//Coin Methods
void Quarter()
{ //OVER HERE!!!! 1
process -= Coins[0];
ncoin++;
}
void Dime()
{ // OVER HERE!!! 2
process -= Coins[1];
ncoin++;
}
void Nickel()
{ //OVER HERE!!! 3
process -= Coins[2];
ncoin++;
}
void Penny()
{ //OVER HERE!!! 4
process -= Coins[3];
ncoin++;
}
}