The following program won't compile correctly. I have the error message being given to me as I try and compile it. Does anyone have a solution? Also, is the last half correct in order to get the box to be drawn with the character selected by the user?
Program:
Code:
#include <stdio.h>
int computeSurfaceArea (int, int, int);
int computeVolume (int, int, int);
void displayTopBottom (int, int);
void displayyFrontBack (int, int);
void displaySide (int, int);
int main ()
{
char choices;
int width;
int height;
int depth;
char symbol,ch1, ch;
int OK;
do {
printf("Enter the width -- must be a positive integer: ");
scanf("%d", &width);
}
while (width < 0);
do
do
{
printf("Enter the height -- must be a positive integer: ");
scanf("%d", &height);
}
while (height < 0);
do
{
printf("Enter the depth -- must be a positive integer: ");
scanf("%d", &depth);
}
while (depth < 0);
printf("Enter a character to be used to draw: ");
scanf("%s", &symbol);
do
{
printf("Menu\n");
printf("A -- Calculate the Surface Area of the Box\n");
printf("V -- Calculate the Volume of the Box\n");
printf("F -- Display the Front/Back of the Box\n");
printf("T -- Display the Top/Bottom of the Box\n");
printf("S -- Display the Side of the Box\n");
printf("Q -- Quit\n");
printf("Please make a selection\n");
scanf("%d",&ch);
ch1 = getchar();
OK = 0;
switch (ch)
{
case 'A':
Volume (height, width, depth);
OK = 1;
break;
case 'F':
FrontBack (width, height);
OK = 1;
break;
case 'T':
TopBottom (width, depth);
OK = 1;
break;
case 'S':
Side (depth, height);
OK =1;
break;
case 'Q':
OK = 1;
break;
default:
printf("Please make another selection\n");
OK = 0;
}
}
while (OK = 0);
return 0;
}
int computeSurfaceArea (int width, int depth, int height)
{
int area = (2 * width * depth) + (2 * height * width) + (2 * depth * height);
return area;
}
int computeVolume (int width, int depth, int height)
{
int volume = (depth * width * height);
return volume;
}
void displayFrontBack(int a , int b )
{
int i,j;
for(j=0; j < b-1;j++)
{for(i=0;i< a-1;i++)
printf("%c",'*');
printf("\n");
}
}
void displayTopBottom(int b , int c )
{
int i,j;
for(j=0; j<b-1; j++)
{for(i=0; i< c-1; i++)
printf("%c", '*');
printf("\n");
}
}
void displaySide(int a , int c )
{
int i,j;
for(j=0; j<c-1; j++)
{for(i=0; i<a-1; i++)
printf("%c", '*');
printf("\n");
}
}
Error message:
/tmp/ccM2czSC.o: In function `main':
/tmp/ccM2czSC.o(.text+0x157): undefined reference to `SurfaceArea'
/tmp/ccM2czSC.o(.text+0x17c): undefined reference to `Volume'
/tmp/ccM2czSC.o(.text+0x197): undefined reference to `FrontBack'
/tmp/ccM2czSC.o(.text+0x1b2): undefined reference to `TopBottom'
/tmp/ccM2czSC.o(.text+0x1cd): undefined reference to `Side'
collect2: ld returned 1 exit status
Thanks!