I have written a program which acts as a contents page for an on-line version of the programming book. When the user types the section number the start page of that section is displayed.
I'm not sure if I have used an array correctly to store section numbers.
It should terminate when user enters zero but it doesn't work.
Code:#include <stdio.h> int main () { char section; int section_number [10]= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; while (section!=0) { for (section=1; section<10; section++) { printf ("\nPlease enter the section number between 1 and 10: "); scanf ("%d", §ion); printf ("\nSection '%d' of C programming book starts at page '%d'\n", section, section_number); } break; } return 0; }
Thank you.



LinkBack URL
About LinkBacks


