I´m using the book c programming for the absolute beginner by michael vine.
Got one more question though, look at this part:
system("cls");
printf ("Enter GPA: ");
scanf ("%f", &iArray[x],x++);
printf("enter another GPA(Y//N?): ");
scanf(" %c", &cResponse);
}while ((x > 30)||(cResponse == 'y' || 'Y'));
Whatever letter i put, it starts the loop again until 30 times, a n or N or whatever doesn´t stop it, what am i missing?
Well, for one, there is this problem with the copy&paste oft he code here, you should put "code" tags around that part. (it's the "hash" (#) button above the forums entry window!)
Beside that, the most obvious problem I see is that you are missing to initialize the variable x in this code snippet, which could lead to all kinds of strange side effects, but then this doesn't seem to be a complete snippet anyway, as there is no start of the while statement at least. This all makes it so much more difficult to help you...
General logic programming issues otherwise are:
- the condition of the while statement "(x > 30)" isn't likely to be true from the start, very suspicious at least without knowing how you initialized it. But then you are incrementing x, so you at least intend likely to start at zero.
- the increment x part is also never executed, as you included that into the scanf ("%f...") statement, which makes me wonder why the compiler doesn't complain about that
- further more, the second condition of the while loop isn't right, as "(cResponse == 'y' || 'Y')" will never be true, you are likely to intend to use "((cResponse == 'y') || (cResponse == 'Y'))"
Ralf