#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
#include <iomanip.h>

#define FALSE 0
#define TRUE 1

float table_req(void);                     //Gets Multiplication Number
int lines_req(const float);                //Gets number of lines
void print_out(const int, const float);    //Print out of Table
int quit(void);                            //Check Continue request y/n
float input_number(void);



void main()
{
  int exit = FALSE;              //Exits program when TRUE
  float table;                   //Multiplication Table
  int lines;                     //Number of lines in table
  do
{
  table = table_req();           //Multiplication table
  lines = lines_req(table);      //Number of Lines in Table
  print_out(lines,table);        //Table Print out Function
  exit=quit();                   //Continue or quit entry
} while (exit==FALSE);           //Continue while exit FALSE
  clrscr();                      //Clear Screen Function
  cout << "\n\n\n\t Program Finished. \n\n";
}

  float table_req(void)
{
  float table;
  do
{
  clrscr();

  cout << "\t\t\t MULTIPLICATION TABLES\n\n\n\n";
  cout << "\n\n\t You can print any table between 1 and 20";
  cout << "\n \t Which times table do you require? ";
  cout << "\n\n \t    Enter a floating point number.. ";

  table = input_number();

} while (table <= 0 || table > 20);
return table;

}


float input_number(void)
{
const int LENGTH=10;

int decimal_point;
int i;
float number
char input_digit[LENGTH];
char key_touched;
int valid;
do
{
  decimal_point = 0;
  valid = TRUE;
  gotoxy(58,10);
  cout << "        ";
  gotoxy(58,10);
  cin.getline(input_digit,LENGTH);
  input_digit[LENGTH-1] = '\0';

  for(i=0; (i<LENGTH && input_digit[i] != '\0'); i++)
{
  switch(input_digit[i])
    {
    case '0':
    case '1':
    case '2':
    case '3':
    case '4':
    case '5':
    case '6':
    case '7':
    case '8':
    case '9':
	    break;
    case '.':decimal_point++;
	   if (decimal_point > 1)
	      {
	      cout << '\a';
	      valid=FALSE;
	      }
	   break;
    default: valid = FALSE;
	   cout <<'\a';
    }
  }
} while (valid == FALSE);
 number = atof(input_digit);

 return number;
}


 int lines_req(const float table)

{
 const int LINESLEN = 4;
 int no_lines=1;
 char input_lines[LINESLEN];

 clrscr();
 do
{
     cout << "\n\n\n \t Lines required in " << table;
     cout << " times table, integers 1 to 14 only. ";
     if (no_lines < 1 || no_lines > 14)
        {
        cout << "\n\n \t   Enter a VALID integer ";
        cout << "between 1 and 14... ";
        }
     else
        {
        cout << "\n\n \t   Enter an integer number ";
        cout << "between 1 and 14...";
        }
     cin.getline(input_lines,LINESLEN);
     input_lines[LINESLEN-1] = '\0';

     no_lines = atoi(input_lines);
} while (no_lines < 1 || no_lines > 14);
return no_lines;

}


void print_out(const int lines, const float table)

{
int n;
clrscr();

cout << "\t " << lines << " LINES OF THE " << table;
cout << " TIMES MULTIPLICATION TABLE \n\n\n\n";
for (n=1; n <= lines; n++)
    {
cout << "\t\t " << n << "\t Times \t " << table << "\t = \t ";
cout << setw(10) << n*table << '\n';
    }
}


int quit(void)
{
char key_pressed;
int exit = FALSE;
do
{
   cout << "\n\n\n\n\n\t Do you wish to quit ? Y or N ";
   key_pressed=getch();

   if (key_pressed != 'Y' && key_pressed != 'y'
        && key_pressed != 'N' && key_pressed != 'n')
	  {
	  cout << "\a\b";
	  clrscr();
	  }
   } while (key_pressed != 'Y' && key_pressed != 'y'
         && key_pressed != 'N' && key_pressed != 'n');

   if (key_pressed == "Y" || key_pressed == 'y')
      exit = TRUE;

   return exit;
}

I get the following 4 errors,

char input_digit[LENGTH];

This is a declaration Syntax Error.

cin.getline(input_digit,LENGTH);

This one is 'Undefined Symbol 'input_digit''

cin.getline(input_digit,LENGTH);

This one is 'Could not find a match for 'istream::getline(undefined,const int)'

if (key_pressed == "Y" || key_pressed == 'y')

and the last error is 'Cannot Convert 'Char' to 'Char *'.

I'm pretty bad at programming and I can't really understand whats wrong with the code here, I suspect its something obvious though.

Thanks in advanced,
and Hello all on DaniWeb.

Your first error is, I think, because you have declared LENGTH with automatic scope. That is it is on the stack, since it is on the stack and gets created when the function is entered it is not a true constant but a variable and so can't be used for array declaration.

try declaring LENGTH static or at global scope.

Errors 2 and 3 are a direct consequence of error 1, ignore them if you fix 1 they will go away.

Error 4, you have "Y" in the if statment instead of 'Y'. You have 'y' correct already.

If this is your exact code then to begin with you should look for missing semi colons.

I wonder what you are using to compile this?!?

Line 59 is missing the ending semicolon, so ..

float number ;

Fixing that should take care of the first three errors.
Note that the variable LENGTH is OK as is, because it is const , so you don't have to change it in any way.

[EDIT]
As implied/suggested both above and below, I also suggest that you switch to a modern compiler, rather sooner than later.

I wonder what you are using to compile this?!?

Judging from the outdated/non-standard headers, void main(), clrscr() my guess is Turbo c++.

@OP you (really) need to update your software to something from the last decade. Something like code::blocks which is free,small & easy. Be sure to download the version with the MinGW compiler combined.

Judging from the outdated/non-standard headers, void main(), clrscr() my guess is Turbo c++.

@OP you (really) need to update your software to something from the last decade. Something like code::blocks which is free,small & easy. Be sure to download the version with the MinGW compiler combined.

Couldn't agree more!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.