### It is not detecting any syntax errors but it just ends instantly.

//********************************************
//File:wk1_change.cpp
//
//Summary: a program that whan given an amount of change will tell you what coins will be needed to equal that amount.
//
//author:
//Created Jan 2020

//*****************************************

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

void intro();
void input( int& amountLeft);
void computeCoins(int& amountLeft, int& qurt,int& dime, int& penny);
void output(int& qurt,int& dime, int& penny);

int main()
{ int amountLeft,
qurt,
dime,
penny;

void intro();
void imput(int& amountLeft);
void computeCoins(int& amountLeft, int& qurt,int& dime, int& penny);
void output( int& qurt,int& dime,int& penny);
return 0;
}

void intro()
{
cout<<"Please enter an amount of money from 1 to 99 cents and I will give the coins equal to that amount";
return;
}

void imput(int& amountLeft)
{
cin>>amountLeft;

while(amountLeft>99||amountLeft<1)
cout<<" Sorry please give a valid amount";
cin>>amountLeft;
return;
}

void computeCoins( int& amountLeft, int& qurt,int& dime, int& penny)
{ while(amountLeft<0)
{
while(amountLeft>=25)
{
amountLeft-25;
qurt++;
}

while(amountLeft>=10)
{
amountLeft-10;
dime++;
}

while(amountLeft>=1)
{
amountLeft-1;
penny++;
}
}
return;
}
void output(int& qurt,int& dime, int& penny)
{ cout<<"Change needed \n";
cout<< "Quarters:"<<qurt<<"\n Dimes:"<<dime<<"/n penny"<<penny;

return;
}

what does it do if you put
cin >> amountLeft;
before return 0 in main?

if that works, its working and just closing before you can see it. Fix by running from a command prompt or adding a cin statement at the end of all your programs.
@jonnin, so you've given up on telling people to use code tags?
At any rate, he's not calling the functions properly in main. Just re-declaring them.
Probably would show up better in code tags.
Look at this carefully and compare it to your original. It now runs but doesn't produce sensible output.

1. Next time use code tags pls.
2. You need to revise how function calls work.
3. You need to spell input consistently. It's not 'input' in one place and 'imput' in another.
4. I'm guessing but '-=' seems more appropriate than '-', but I haven't double checked - that's your project therefore your job.
5. 'when' isn't spelled 'whan'
6. Always initialise variables.
7. The idea, especially if it's your own, isn't too bad at all, so persevere with it because there isn't a lot to fix :)

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283`` ``````//******************************************** //File:wk1_change.cpp // //Summary: a program that whan given an amount of change will tell you what coins will be needed to equal that amount. // //author: //Created Jan 2020 //***************************************** #include #include #include using namespace std; void intro(); void input( int& amountLeft); void computeCoins(int& amountLeft, int& qurt,int& dime, int& penny); void output(int& qurt,int& dime, int& penny); int main() { int amountLeft{0}, qurt{0}, dime{0}, penny{0}; intro(); input( amountLeft ); computeCoins( amountLeft, qurt, dime, penny); output(qurt, dime, penny); return 0; } void intro() { cout<<"Please enter an amount of money from 1 to 99 cents and I will give the coins equal to that amount"; return; } void input(int& amountLeft) { cin>>amountLeft; while(amountLeft>99||amountLeft<1) { cout<<" Sorry please give a valid amount"; cin >> amountLeft; } return; } void computeCoins( int& amountLeft, int& qurt,int& dime, int& penny) { while(amountLeft < 0) { while(amountLeft >= 25) { amountLeft -= 25; qurt++; } while(amountLeft >= 10) { amountLeft -= 10; dime++; } while(amountLeft >= 1) { amountLeft -= 1; penny++; } } return; } void output(int& qurt,int& dime, int& penny) { cout<<"Change needed\n"; cout<< "Quarters:" << qurt << "\n Dimes: " << dime << "/npenny " <
Last edited on
@jonnin, so you've given up on telling people to use code tags?

Well, I didn't look at the code because of tagsā¦ but gave the default 'blink and gone' answer in case it was that.
Type:
`System("pause")`
or
`cin.get()`

This worked for me, so I hope it will work for you.

bpt
Topic archived. No new replies allowed.