#include <iostream>
#include <conio.h>
#include <cstdlib>
using namespace std;
int main ()
{
char ans;
do
{
int i, n, sum;
int array [100];
cout << "Enter array size: ";
cin >> n;
cout << "Enter " << n << " numbers: " << endl;
for (i=0; i<n; i++)
{
cin >> array [i];
}
sum = 0;
for (i=0; i<n; i++)
{
sum = sum + array [i];
}
cout << endl;
cout << "Sum is: " << sum << " " << endl;
cout << endl;
int amount, a,b,c,d,e,f,g;
int result; // initial value unidentified
int var1 = 1000; //initial value = 1000
int var2 = 500; //initial value = 500
int var3 = 100; //initial value = 100
int var4 = 50; //initial value = 50
int var5 = 20; //initial value = 20
int var6 = 10; //initial value = 10
int var7 = 1; //initial value = 1
for (i=0; i<n; i++)
{
a = array [i]/var1;
if (a!=0)
cout << "1000 : "<< a << endl;
}
for (i=0; i<n; i++)
{
b = (array [i]%var1)/var2;
if (b!=0)
cout << "500 : "<< b << endl;
}
for (i=0; i<n; i++)
{
c = (array [i]%var1)%var2/var3;
if (c!=0)
cout << "100 : "<< c << endl;
}
for (i=0; i<n; i++)
{
d = (array [i]%var1)%var2%var3/var4;
if (d!=0)
cout << "50 : "<< d << endl;
}
for (i=0; i<n; i++)
{
e =(array [i]%var1)%var2%var3%var4/var5;
if (e!=0)
cout << "20 : "<< e << endl;
}
for (i=0; i<n; i++)
{
f = (array [i]%var1)%var2%var3%var4%var5/var6;
if (f!=0)
cout << "10 : "<< f << endl;
}
for (i=0; i<n; i++)
{
g = (array [i]%var1)%var2%var3%var4%var5%var6/var7;
if (g!=0)
cout << "1 : "<< g << endl;
}
cout << "Do you want to try again? ";
cin >> ans;
system("cls");
}
while (ans == 'y');
getch ();
}
*********************
example output:
Enter array size: 3
Enter 3 numbers:
1000
1000
1000
Sum is: 3000
1000: 1
1000: 1
1000: 1
*************
what I want to do is simply like this
1000: 3
Can you help me with my problem? Thanks in advance!