# Thread: wats wrong with this code?

1. ## wats wrong with this code?

Code:
```void blue(int q,int r, int s, int t, int u)
{int a;
clrscr();
printf("\n\n\t\t\tThe players of Team Blue:");
printf("\n\n\n\t\t\t   %d",q);
printf("\n\n\n\t\t\t   %d",r);
printf("\n\n\n\t\t\t   %d",s);
printf("\n\n\n\t\t\t   %d",t);
printf("\n\n\n\t\t\t   %d",u);
printf("\n\n\n\t\t\tWhich player has the ball?");
printf("\n\n\n\t\t\tEnter the number of the player:   ");
scanf("%d",&a);
if(a==1)
one();
getch();
}
void green(int v,int w, int x, int y, int z)
{printf("%d,%d,%d,%d,%d", v,w,x,y,z);
}
void one()
{
int a ;
int x[20];
printf("\n\n\n\t\tPlayer number 1 of Team Blue has shoot the ball.");
printf("\n\n\t\t\t2- two points for lay-up shot");
printf("\n\n\t\t\t3- for three point shot");
printf("\n\n\n\t\t\tEnter a score:   ");
scanf("%d", &a);
scores();
getch();
}```
it ends with choosing the number of the player.....

2. I don't know. You tell me what's wrong and I'll tell you how to solve it.

3. Originally Posted by OnionKnight
I don't know. You tell me what's wrong and I'll tell you how to solve it.
after choosing the number of the player...it stops...

iy should go to function one();

4. do you have function prototypes at the top of your file(above the main function)?

5. Originally Posted by System_159
do you have function prototypes at the top of your file(above the main function)?
yes

#include <stdio.h>
#include<conio.h>
#include<ctype.h>

Code:
```#include <stuff>

void blue(int, int, int, int, int);
void green();
void one();

int main()
{
return(0);
}

void blue(int q,int r, int s, int t, int u)
{int a;
clrscr();
printf("\n\n\t\t\tThe players of Team Blue:");
printf("\n\n\n\t\t\t   %d",q);
printf("\n\n\n\t\t\t   %d",r);
printf("\n\n\n\t\t\t   %d",s);
printf("\n\n\n\t\t\t   %d",t);
printf("\n\n\n\t\t\t   %d",u);
printf("\n\n\n\t\t\tWhich player has the ball?");
printf("\n\n\n\t\t\tEnter the number of the player:   ");
scanf("%d",&a);
if(a==1)
one();
getch();
}
void green(int v,int w, int x, int y, int z)
{printf("%d,%d,%d,%d,%d", v,w,x,y,z);
}
void one()
{
int a ;
int x[20];
printf("\n\n\n\t\tPlayer number 1 of Team Blue has shoot the ball.");
printf("\n\n\t\t\t2- two points for lay-up shot");
printf("\n\n\t\t\t3- for three point shot");
printf("\n\n\n\t\t\tEnter a score:   ");
scanf("%d", &a);
scores();
getch();
}```

7. Code:
```#include <stdio.h>
#include<conio.h>
#include<ctype.h>
void new_game1();
void blue(int q,int r, int s, int t, int u);
void green(int v,int w, int x, int y, int z);
void player1();
void exit();
void game();
void one();
void scores();
void main()
{int a,c;
clrscr();
printf("\n\n\n\n\n\t\t\t   1 - start new game");
printf("\n\n\t\t\t   2 - quit game");
printf("\n\n\n\n\n                                    ");
scanf("%d",&a);
if(a==1)
{new_game1();}
else if(a==2)
{exit();}
else
printf("\n\n\t\t\tYou've entered an invalid choice.");
getch();
}
void new_game1()
{
int a,b,c,d,e,f,g,h,i,j,k,l;
clrscr();
printf("\tTEAM BLUE");
printf("\n\n\n\t   1");
printf("\n\n\n\t   12");
printf("\n\n\n\t   2");
printf("\n\n\n\t   9");
printf("\n\n\n\t   8");
printf("\n\n\n\t   21");
printf("\n\n\n\t   25");
printf("\n\n\n\t   5");
printf("\n\n\n\t   13");
printf("\n\n\n\t   14");
printf("\n\n\t\tPlease choose 5 players from each team.");
printf("\n\n\t\t1st player: ");
scanf("%d", &b);
printf("\n\n\t\t2nd player: ");
scanf("%d", &c);
printf("\n\n\t\t3rd player: ");
scanf("%d", &d);
printf("\n\n\t\t4th player: ");
scanf("%d", &e);
printf("\n\n\t\t5th player: ");
scanf("%d", &f);
printf("\n");
printf("\tTEAM GREEN");
printf("\n\n\n\t   3");
printf("\n\n\n\t   11");
printf("\n\n\n\t   7");
printf("\n\n\n\t   4");
printf("\n\n\n\t   5");
printf("\n\n\n\t   9");
printf("\n\n\n\t   2");
printf("\n\n\n\t   6");
printf("\n\n\n\t   10");
printf("\n\n\n\t   14");
printf("\n\n\t\tPlease choose 5 players from each team.");
printf("\n\n\t\t1st player: ");
scanf("%d", &g);
printf("\n\n\t\t2nd player: ");
scanf("%d", &h);
printf("\n\n\t\t3rd player: ");
scanf("%d", &i);
printf("\n\n\t\t4th player: ");
scanf("%d", &j);
printf("\n\n\t\t5th player: ");
scanf("%d", &k);
printf("\n\nThe players you have chosen for Team Blue are %d,%d,%d,%d,%d",b,c,d,e,f);
printf( "\n\nThe players you have chosen for Team Green are %d,%d,%d,%d,%d",g,h,i,j,k);
printf("\n\n\n\n");
printf("Let's start the game!!!");
printf("\n\n\n\nJUMPBALL!!!");
printf("\n\n\n\n\n\n\n\nBall possesion goes to Team?");
printf("\n\n\t\t\t1 - Team Blue");
printf("\n\n\t\t\t2 - Team Green");
printf("   ");
scanf("%d", &l);
if(l==1)
blue(b,c,d,e,f);
else if(l==2)
green(g,h,i,j,k);
}
void exit()
{
printf("\n\n\t\t\tThank you for using this program");
getch();
}
void blue(int q,int r, int s, int t, int u)
{int a;
clrscr();
printf("\n\n\t\t\tThe players of Team Blue:");
printf("\n\n\n\t\t\t   %d",q);
printf("\n\n\n\t\t\t   %d",r);
printf("\n\n\n\t\t\t   %d",s);
printf("\n\n\n\t\t\t   %d",t);
printf("\n\n\n\t\t\t   %d",u);
printf("\n\n\n\t\t\tWhich player has the ball?");
printf("\n\n\n\t\t\tEnter the number of the player:   ");
scanf("%d",&a);
if(a==1)
one();
getch();
}
void green(int v,int w, int x, int y, int z)
{printf("%d,%d,%d,%d,%d", v,w,x,y,z);
}
void one()
{
int a ;
int x[20];
printf("\n\n\n\t\tPlayer number 1 of Team Blue has shoot the ball.");
printf("\n\n\t\t\t2- two points for lay-up shot");
printf("\n\n\t\t\t3- for three point shot");
printf("\n\n\n\t\t\tEnter a score:   ");
scanf("%d", &a);
scores();
getch();
}
void scores()
{clrscr();
printf("   TEAM BLUE\t\tscores\t\t\TEAM GREEN\t\tscores");
printf("\n\n\n\n      1\t\t\t\t\t  3");
printf("\n\n\n      12\t\t\t\t  11");
printf("\n\n\n      2\t\t\t\t\t  7");
printf("\n\n\n      9\t\t\t\t\t  4");
printf("\n\n\n      8\t\t\t\t\t  5");
printf("\n\n\n      21\t\t\t\t  9");
printf("\n\n\n      25\t\t\t\t\t  2");
printf("\n\n\n      5\t\t\t\t  6");
printf("\n\n\n      13\t\t\t\t\t  10");
printf("\n\n\n      14\t\t\t\t\t  14");
getch();
}
threept(int a)
{int c;
c=a+3;
return c;
}
onept(int a)
{int c;
c=a+1;
return c;
}
twopt(int a)
{int c;
c=a+2;
return c;
}```
this is the whole code.....

actually we'll have to include the highest score.. what team got the highest score so that they will declared as the winner.. also the mVP player...

8. iy should go to function one();
After I fixed some warnings from the compiler - it goes there...
So the problem (besides the void main and missing indentetion) is somewhere else.

9. Originally Posted by vart
After I fixed some warnings from the compiler - it goes there...
So the problem (besides the void main and missing indentetion) is somewhere else.
what part of program?
awts....i dont know how to fix it up coz i dont have enough knowledge bout C.

10. what part of program?
The right question here is
What problem do you have? Because the problem you noted actually does not exist.
And this question only you can answer.

11. Originally Posted by vart
The right question here is
What problem do you have? Because the problem you noted actually does not exist.
And this question only you can answer.
after i entered the number of the player
Code:
```printf("\n\n\n\t\t\tEnter the number of the player:   ");
scanf("%d",&a);
if(a==1)
one();
getch();
}```
its here right?

then...it stops there....
after i entered for example player number 9...
it goes in the next line.. then after i pressed any key...it goes back to the compiler...

12. it should
because you ask to run function one() only when a == 1

13. Originally Posted by vart
it should
because you ask to run function one() only when a == 1
what if i delete the a==1?

14. what if i delete the a==1?
what if you delete it?

15. Originally Posted by vart
what if you delete it?
ill try...i dont know what will happen next...

do you know how to tabulate all the scores that user had input?