[#include <cstdlib> // please dont tease first c++ class and im bombing it so far due to
not fully understanding what it is i am doing exactly i know this is insanely
wrong i just dont understand the correct logic
int main (intargc, char* argv)
int MAXADS = 100; // not sure if i did this right to begn is this some kind of constand int?
cout <<"please enter the number of ads:" cin>> endl // i know this part is quite messed up
i am about terrible at the cout clauses
[for (i >0; numads-1)]
//for i = 0 and numads-1 // not sure if this is remotly what i should be doing here..
[for (i=0 numads-2)]
[for (j=0 numads-2)// not sure about these 2 for s]
[if (j>[j+1] )]
[temp = [j] =[j+1]]
//and thats about as far as i got the following beyond i know my while // if i could just get it broken down to where i can make sence of it i systematically took each section of the
algorithm and tryed to make some code out of it but its terrible it would be humiliating to post the rest as you can see i am not good with this problem im trying to solve
its mainly due to not taking this inclass and having any type of tutor or help with these things the book shows me some of this but not nearly enough to give good concrete example
of the excercise im trying to accomplish. i am to embarassed to post the rest of this hog wash ... ;(
not sure what you mean by code tags but im assuming the //?
int adcatcode[MAXADS]; is what it should be but you did the first declaration correctly. I'd define it as const int though if you don't expect it to change.
Remember to wrap the code in [ code] tags when you post here...
constint MAXADS = 100;
...no idea why you're including cstdlib...might as well get rid of it.
Edit, okay lemme explain line 6?
1 2 3 4 5 6
int MAXADS = 100; /* Here you are defining a variable as an integer, those are the
first two words. Then you are 'assigning' ( = ) the variable the value of 100.
So this is perfectly valid*/
int adcatcode; /* While technically correct this isn't what your pseudocode wants you
to do. Your adcatcode is an 'array' of integers, but you don't want to define it as 100, you
want to define it as whatever the value is contained in MAXADS (ergo my previous example)*/
This is the whole point about 'variables' think Algebra. They are there as placeholders that you can change later. (You'll go meta on this later with pointers).
"We have zero counters, print how many counters we have then increase counters by 1 until we have 10 counters. " Is pretty much what we're thinking here.
I found issues with the Pseudocode. Your first for loop (as far as I can tell) shouldn't be 'numads - 1' it should just be 'numads' otherwise you'll never assign all of your adverts.
Tip for readability (screw the lecturer)
cout << "Please enter Advert number " << i + 1 << " Category Code (1-15)" << endl;
cin >> adcatcode[i];
Your first cout should be as follows. The reason for this is because otherwise you don't know which advert you're inputting. The i+1 is specifically for readability only, we don't normally count from 0 we usually count from 1. So your first advert would be 1. But in your code, thanks to arrays it would be assigned to 0 instead. (That was a fun exercise, thanks!)