help pls

can someone help me how to breakdown? sample

Enter the number : 7689

P1000 = 7
P500 = 1
P200 = 0
P100 = 1
P50 = 1
P20 = 1
P10 = 1
P5 = 0
P1 = 4

Last edited on
It looks like you are to take a number and print out each place value by the listed increments? Can you post the code you have tried?
It seems like you want to make the number into cash, i guess the value of "p5" should be 1, could you show me your code or more details?
oh im sorry yes P5 is = 1

my sample code here

#include <conio.h>
#include <iostream.h>

int money, breakdown1, breakdown2;

void main()
{
clrscr();

cout<<"Enter the Amount of money : ";
cin>>money;

breakdown1 = money;

breakdown1 =money / 1000;
breakdown2 = money % 1000;
money = breakdown2;

cout<<"\nP1000 : = "<<breakdown1;

breakdown1 = money / 500;
breakdown2 = money % 500;
money = breakdown2;

cout<<"\nP500 : = "<<breakdown1;

breakdown1 = money / 200;
breakdown2 = money % 200;
money = breakdown2;

cout<<"\nP200 : = "<<breakdown1;

breakdown1 = money / 100;
breakdown2 = money % 100;
money = breakdown2;

cout<<"\nP100 : = "<<breakdown1;

breakdown1 = money / 50;
breakdown2 = money % 50;
money = breakdown2;

cout<<"\nP50 : = "<<breakdown1;

breakdown1 = money / 20;
breakdown2 = money % 20;
money = breakdown2;

cout<<"\nP20 : = "<<breakdown1;

breakdown1 = money / 10;
breakdown2 = money % 10;
money = breakdown2;

cout<<"\nP10 : = "<<breakdown1;

breakdown1 = money / 5;
breakdown2 = money % 5;
money = breakdown2;

cout<<"\nP5 : = "<<breakdown1;

breakdown1 = money / 1;
breakdown2 = money % 1;
money = breakdown2;

cout<<"\nP1 : = "<<breakdown1;

getch();
}

but when i put in Dev++ it will error
Did you save it as a .cpp project?

What are the errors??

Unfortunately I don't have Dev++ to test it but it does work with the Code::Blocks IDE when I change void main to int main and commented out clrscr()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <iostream>
#include <conio.h>

using namespace std;




int money, breakdown1, breakdown2;

int main()
{
//clrscr();

cout<<"Enter the Amount of money : ";
cin>>money;

breakdown1 = money;

breakdown1 =money / 1000;
breakdown2 = money % 1000;
money = breakdown2;

cout<<"\nP1000 : = "<<breakdown1;

breakdown1 = money / 500;
breakdown2 = money % 500;
money = breakdown2;

cout<<"\nP500 : = "<<breakdown1;

breakdown1 = money / 200;
breakdown2 = money % 200;
money = breakdown2;

cout<<"\nP200 : = "<<breakdown1;

breakdown1 = money / 100;
breakdown2 = money % 100;
money = breakdown2;

cout<<"\nP100 : = "<<breakdown1;

breakdown1 = money / 50;
breakdown2 = money % 50;
money = breakdown2;

cout<<"\nP50 : = "<<breakdown1;

breakdown1 = money / 20;
breakdown2 = money % 20;
money = breakdown2;

cout<<"\nP20 : = "<<breakdown1;

breakdown1 = money / 10;
breakdown2 = money % 10;
money = breakdown2;

cout<<"\nP10 : = "<<breakdown1;

breakdown1 = money / 5;
breakdown2 = money % 5;
money = breakdown2;

cout<<"\nP5 : = "<<breakdown1;

breakdown1 = money / 1;
breakdown2 = money % 1;
money = breakdown2;

cout<<"\nP1 : = "<<breakdown1;

getch();
}

I dont have DEV++ either,but i've tested your code and commented out some codes, i think you need to put namespace std in your program like:
"std::cout" or "using namespace std"


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <iostream>
//#include <conio.h>

using namespace std;

int money, breakdown1, breakdown2;

int main()
{
//clrscr();

cout<<"Enter the Amount of money : ";
cin>>money;

breakdown1 = money;

breakdown1 =money / 1000;
breakdown2 = money % 1000;
money = breakdown2;

cout<<"\nP1000 : = "<<breakdown1;

breakdown1 = money / 500;
breakdown2 = money % 500;
money = breakdown2;

cout<<"\nP500 : = "<<breakdown1;

breakdown1 = money / 200;
breakdown2 = money % 200;
money = breakdown2;

cout<<"\nP200 : = "<<breakdown1;

breakdown1 = money / 100;
breakdown2 = money % 100;
money = breakdown2;

cout<<"\nP100 : = "<<breakdown1;

breakdown1 = money / 50;
breakdown2 = money % 50;
money = breakdown2;

cout<<"\nP50 : = "<<breakdown1;

breakdown1 = money / 20;
breakdown2 = money % 20;
money = breakdown2;

cout<<"\nP20 : = "<<breakdown1;

breakdown1 = money / 10;
breakdown2 = money % 10;
money = breakdown2;

cout<<"\nP10 : = "<<breakdown1;

breakdown1 = money / 5;
breakdown2 = money % 5;
money = breakdown2;

cout<<"\nP5 : = "<<breakdown1;

breakdown1 = money / 1;
breakdown2 = money % 1;
money = breakdown2;

cout<<"\nP1 : = "<<breakdown1;

//getch();
}
does DEV-C++ 5.11 is working? i tried it a lot but the error is #include <iostream.h> and i don't know why :< my codes is accurate and my friend tried too and it's working when i'm try it in Dev-C++ 5.11 it has error.
Topic archived. No new replies allowed.