Are there any online resources that give you real world references and example code? My problem is that my homework on arrays involves looking through an array and listing only certain values. Our lessons have only done simple equations like making 3 dimensional arrays to find the sum[i] of num1[i] and num2[i]. Really simple stuff.
Here's my problem. I need to print a list of Ids of sales over 5000, then the number of records with sales less than 500. I was able to figure out the latter with a simple count, but the former.. I can only print out one entry and it is often incorrect. I learn by examples so I'm not sure where I'm going wrong with what we've gone over already. Here is my program:
#include <iostream.h>
int main()
{
int names[5], sales[5], greater[5];
int i;
for (i=0; i<5; i++)
{
cout<<"enter id and sale amount: ";
cin>>names[i]>>sales[i];
}
int count =0;
for (i=0;i<5;i++)
{
if (sales[i]> 5000)
names[i] = greater[i];
if (sales[i] < 500)
count++;
}
cout<<"\nID of sales greater than 5000: "<<endl;
cout<<greater[i];
cout<<"\nNumber of sales less than 500: "<<count;
return 0;
}