- English -
Resident Freddy
- Joined
- Apr 7, 2004
- Messages
- 5,263
Code:
#include <stdio.h>
#define ROWS 6 //define number of rows; change here to change everywhere
#define COLUMNS 6 //define number of columns; change here to change everywhere
void menu();
#define Display_distance();
#define Calc_cost();
#define Mileage_chart();
#define Exit();
void Mileage_chart(int Array2D[][]); //declaration of a function
int main() {
int i,j;
int Array2D[ROWS][COLUMNS];
for(i=0; i<ROWS; i++) {
printf("Please Enter 6 Distances. Include a space between each: \n");
for(j=0; j <COLUMNS; j++) {
scanf_s("%d" , &Array2D[i][j]);
}
printf("\n");
}
printf("The Distances you entered are: \n");
for(i=0; i<ROWS; i++) {
for(j=0; j<COLUMNS; j++) {
printf("%d ", Array2D[i][j]);
}
printf("\n");
}
menu();
menu(Array2D);
return 0;
}
void menu(void) {
int input;
printf("\n");
printf( "1. Display Distance Between Two Points\n" );
printf( "2. Calcuate Cost of a Journey at 40p per mile\n" );
printf( "3. Display On Screen the full Mileage Chart\n" );
printf( "4. Exit\n" );
printf( "Selection: " );
scanf_s( "%d", &input );
switch ( input ) {
case 1:
Display_distance();
break;
case 2:
Calc_cost();
break;
case 3:
Mileage_chart();
Mileage_chart(Array2D);
break;
case 4:
Exit();
break;
default:
printf( "Bad input, Exiting Program\n" );
break;
}
getchar();
}
Im trying to get the printed output of the 2d array to be displayed through case#3. Can anyone see where im going wrong?:/