Hello,

I am currently working on an algorithm and i am quite confused.

The algoritm is:

Put q = 19
1. For i=1 to 3
If the ith element of the list is a letter then
If the letter’s position in the alphabet is an odd number then
q = q+ 4
else
If the ith element is numeral n then
q = q + n.
2. Return q.

I have AB56 for the category number(the list). What I did was that I used a table with 3 columns. i, CatNumber and d. But I am still confused how to fill the table.
by following the algorithm. Should I have an additional q column in the table?

Thanks

anyone?

Notice that only three first letters have effect, rest of input does not count for result. categorize three columns with the two alternative branches and third for other input(like space or punctuation) for pass.

You should list all variables in the algorithm

Yes I know about listing all the variables however I don't know in what format I should display the variables and the step it changes. Will a table do?

Yes, just whatever that suits you best. 'Trace' table is probably the best

Ok thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.