Whenever my print statements execute the print the values fine but they reverse their order...the first value gets printed and it kinds of moves down and the second value moves on top, but i want the first value on top and the second value on the bottome and etc. Code highlighted in red are the main print statements
Code:
//ASSIGNMENT 1, TENNIS GAME
#include <stdio.h>
#define PRINT 0
#define GAME_A 1
#define GAME_B 2
#define DEUCE 3
#define AD_SERVER 4
#define AD_RECEIVER 5
int scoreA = 0;
int scoreB = 0;
int scoreFunct(char c, char team);
void printFunct(int scoreA, int scoreB, char c, char team);
int main (int argc, char **argv){
char team;
char c;
printf ("Team A or Team B serves first?:\n");
while((team = getchar()) != EOF){
if((team == 'A') || (team == 'a') || (team == 'B') || (team == 'b')){
printf("\nTeam %c to serve\n", team);
}
break;
}
scoreFunct(c,team);
return(0);
}
int scoreFunct(char c, char team){
while((c = getchar()) != EOF){
if ((c == 'S') || (c == 's')){
printFunct(scoreA,scoreB,c,team);
return(PRINT);
}
else if((c == 'B') || (c == 'b')){
if(scoreB < 30){
scoreB+=15;
}
else if(scoreB == 30){
scoreB+=10;
}
}
else if((c == 'A') || (c == 'a')){
if(scoreA < 30){
scoreA+=15;
}
else if(scoreA == 30){
scoreA+=10;
}
}
}
return(0);
}
void printFunct(int scoreA, int scoreB, char c, char team){
if(scoreFunct(c,team) == PRINT){
if((scoreA == 0) && (scoreB == 0)){
printf("Love-All\n");
printf("\n");
}
else if((scoreA > 0) && (scoreB > 0)){
printf("Team %c to serve\n", team);
printf("%d-%d\n", scoreA, scoreB);
printf("\n");
}
else if((scoreA == 0) && (scoreB > 0)){
printf("Team %c to serve\n", team);
printf("Love-%d\n",scoreB);
printf("\n");
}
else if((scoreA > 0) && (scoreB == 0)){
printf("Team %c to serve\n", team);
printf("%d-Love\n",scoreA);
printf("\n");
}
}
}