Note that there are some explanatory texts on larger screens.

plurals
  1. POScan single character C
    primarykey
    data
    text
    <pre><code>/* Program to calculate trip and plan flights */ #define TRIP 6 #define DEST 1 #include &lt;stdio.h&gt; int error_dest(int type_num, int cont_num, int dest_code, int check); int main(void) { int check, type_num, cont_num, index, i, dest_code, trip_num, row, col; int travelint[TRIP][DEST], travelarea[TRIP]; char area_code, S, M, L, N, P, K, R, C, U, W, O; trip_num = 7; while (trip_num &gt; TRIP) { printf("Please enter the number of trips:"); scanf("%d", &amp;trip_num); if ( trip_num &lt; TRIP) { printf("Valid trip number. Please proceed to enter destination code.\n"); } else { printf("Invalid trips. Please enter no more then 6 trips.\n"); } } /*********************************************************************************/ for (i=0; i &lt; trip_num ; i++) /*destination code input*/ { printf("Please enter destination code:"); scanf("%d", &amp;dest_code); /*input of destination code*/ check = error_dest(type_num, cont_num, dest_code, check); if (check == 2) { travelint[i][0]=dest_code; } else { while (check == 1) { printf("Please enter destination code:"); scanf("%d", &amp;dest_code); /*input of destination code*/ check = error_dest(type_num, cont_num, dest_code, check); if (check == 2) { travelint[i][0]=dest_code; } } } printf("Please select from the following that best describes your destination:\n"); printf("S Small city - population under 50,000\n"); printf("M Medium city - population between 50,000 and 500,000\n"); printf("L Large city - pop. over 500,000\n"); printf("N Natural formation like a mountain, a lake, a cave, a geyser, a fjord, a canyon, etc.\n"); printf("P Designated park or reserve such as a wildlife refuge, a national park, a bioreserve, or a protected marine area\n"); printf("K Man made landmark like the Great Wall of China, the Taj Mahal, or Stonehenge\n"); printf("R State or province or region of a country\n"); printf("C Whole country\n"); printf("U Multiple countries like traveling through Europe\n"); printf("W Ocean voyage\n"); printf("O Any other type of destination - such as visiting the sites of the seven wonders of the world\n"); printf("Please enter the Area Letter code:"); scanf("%c", &amp;area_code); } /*******************************************************************************/ /*print for destination_code*/ for (row = 0; row &lt; trip_num; row++) { for (col=0; col &lt; DEST; col++) printf("Trip[%d] = %d\n", row+1, travelint[row][col]); } return 0; } error_dest(type_num, cont_num, dest_code, check) { cont_num = dest_code / 10000; /*math for error check*/ type_num = dest_code/1000 - cont_num*10; if ( (cont_num &lt;= 7) &amp;&amp; (cont_num &gt; 0) &amp;&amp; (type_num &lt;= 5) &amp;&amp; (type_num &gt;=0) ) { /* loop for checking destination code*/ check = 2 ; return check; } else { printf("%d is a invalid code\n", dest_code); check = 1; return check; } } </code></pre> <p>for some strange reason at the scanf("%c", &amp;area_code); it just runs ahead and print the dest_code array without letting me input any character and I'm not sure what exactly I am doing wrong. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload