Hey guys,

I had to make a basketball score board, and I've run into some errors. Here's my code so far:

#include <stdio.h>
#include "genlib.h"
#include "simpio.h"
#include "strlib.h"    


main()
{
   int t, tw, tp, r, rw, rp, j, jw, jp, f, fw, fp;
   printf("How many games did the Tigers play?");
   t = GetInteger();
   printf("How many games did the Tigers win?");
   tw = GetInteger();
   clrscr();

   printf("How many games did the Rockets play?");
   r = GetInteger();
   printf("How many games did the Rockets win?");
   rw = GetInteger();
   clrscr();

   printf("How many games did the Jumpers play?");
   j = GetInteger();
   printf("How many games did the Jumpers win?");
   jw = GetInteger();
   clrscr();

   printf("How many games did the Flyers play?");
   f = GetInteger();
   printf("How many games did the Flyers win?");
   fw = GetInteger();
   clrscr();

   tp = tw / t * 100;
   rp = rw / r * 100;
   jp = jw / j * 100;
   fp = fw / f * 100;

   printf("                  Basketball Season               /n");
   printf("Name     Games Played   Games Won    Percent Of Wins");
   printf("Tigers   %d             %d           %d              ", t, tw, tp);
   printf("Rockets  %d             %d           %d              ", r, rw, rp);
   printf("Jumpers  %d             %d           %d              ", j, jw, jp);
   printf("Flyers   %d             %d           %d              ", f, fw, fp);


getch();

}

And here are the errors I am getting:

Compiler: Default compiler
Executing  gcc.exe...
gcc.exe "C:\Users\HyperCriticality\Desktop\basketball.c" -o "C:\Users\HyperCriticality\Desktop\basketball.exe"    -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib" 
C:\Users\HYPERC~1\AppData\Local\Temp/ccQDeaaa.o(.text+0x911):basketball.c: undefined reference to `clrscr'
C:\Users\HYPERC~1\AppData\Local\Temp/ccQDeaaa.o(.text+0x93e):basketball.c: undefined reference to `clrscr'
C:\Users\HYPERC~1\AppData\Local\Temp/ccQDeaaa.o(.text+0x96b):basketball.c: undefined reference to `clrscr'
C:\Users\HYPERC~1\AppData\Local\Temp/ccQDeaaa.o(.text+0x998):basketball.c: undefined reference to `clrscr'
collect2: ld returned 1 exit status

Execution terminated

Could I have a hand with this? I really need this done...

Hey i think the problem is with the header files:

clrscr(); 

and getch();

requires the header file conio.h

i.e #include <conio.h>

This is wrong !

#include "genlib.h"
#include "simpio.h"
#include "strlib.h" 

You have to use :

#include <simpio.h>
#include <strlib.h>
#include <conio.h>
#include <genlib.h>

Edited 4 Years Ago by RainbowMatrix

include stdlib header for this
then try
system("clear");
for clearing the console screen for gcc compilers

just a note, In Dev C++ I think it's system("CLS")

Edited 4 Years Ago by zeroliken

#include <stdio.h>
#include <iostream>

....
add

using namespace std;

i am getting the perfect output now

Edited 4 Years Ago by RainbowMatrix

It works!
Thanks guys!

How would I allign the columns so the numbers are always in a line? is there a way to do that?

Wait...now it will only return results of 100 percent or more?

Edited 4 Years Ago by Hyperion101: New error.

I just made an edit see this

#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
    int t, tw, tp, r, rw, rp, j, jw, jp, f, fw, fp;
    printf("How many games did the Tigers play? ");
    cin>>t;
    cout<<endl;
    printf("How many games did the Tigers win? ");
    cin>>tw;
    cout<<endl;
    printf("How many games did the Rockets play? ");
    cin>>r;
    cout<<endl;
    printf("How many games did the Rockets win? ");
    cin>>rw;
    cout<<endl;;

    printf("How many games did the Jumpers play? ");
    cin>>j;
    cout<<endl;
    printf("How many games did the Jumpers win? ");
    cin>>jw;
    cout<<endl;
    printf("How many games did the Flyers play? ");
    cin>>f;
    cout<<endl;
    printf("How many games did the Flyers win? ");
    cin>>fw;
    cout<<endl;

    tp = tw / t * 100;
    rp = rw / r * 100;
    jp = jw / j * 100;
    fp = fw / f * 100;
    printf(" Basketball Season \n");
    printf("\nName Games Played Games Won Percent Of Wins\n");
    printf("\nTigers  %d %d %d ", t," ", tw," ", tp,"\n");
    printf("\nRockets %d %d %d ", r, " ",rw," ", rp,"\n");
    printf("\nJumpers %d %d %d ", j, " ",jw, " ",jp,"\n");
    printf("\nFlyers  %d %d %d ", f," ", fw," ", fp,"\n");
    cout<<"\n\n";
}
Comments
You mean a complete rewrite into C++ This si the C forum.

Ok then just use this to allign the numbers:

printf("\nTigers %d %d %d ", t," ", tw," ", tp,"\n");
printf("\nRockets %d %d %d ", r, " ",rw," ", rp,"\n");
printf("\nJumpers %d %d %d ", j, " ",jw, " ",jp,"\n");
printf("\nFlyers %d %d %d ", f," ", fw," ", fp,"\n");

You can space the numbers properly by adding the width value:
printf("\nTigers %3d %3d %3d ", t," ", tw," ", tp,"\n");

This prints all numbers with 3 chracters, SPACE filled.

Also, division can't be done accurately with integers. Make a test program to see what happens when dividing various integer values.

Just comment out clrscr(), it is sort of silly to use.

Mostly a leftover from the rather outdated Turbo C.

Edited 3 Years Ago by HiHe

This article has been dead for over six months. Start a new discussion instead.