again I use the function only to express the idea, The point being, you already have a switch-case, and it would make sense to set both ch and variable at the same time.
Its a homework I have to make a Touring machine. I have to make my program the same as Touring machine would work (without break functions or simpler code e.c.) I define char as state in witch it is.
I have to make my program the same as Touring machine would work (without break functions or simpler code e.c.)
Well, I only suggested switch-case since that was what you posted. Note that without the break; the code posted at first would not work as intended. number 1, 5 or 7 would all give the same outcome, ch = 'z'.
1 2 3 4 5 6
switch (number) {
case 1: ch='x';
case 5: ch='y';
case 7: ch='z';
}
I get the feeling we're all engaged in a merry dance here, where after several posts back and forth, we still may not have reached the actual question.