-1
#include<stdlib.h>
#include<stdio.h>
int calculo(int pontos, int placar1, int placar2);
int main()
{
int c;
int placar1, placar2;
char bet1n[30], bet2n[30], bet3n[30], bet4n[30], bet5n[30];
int bet1a = 0, bet1b = 0, bet2a = 0, bet2b = 0, bet3a = 0, bet3b = 0, bet4a = 0, bet4b = 0, bet5a = 0, bet5b = 0;
int p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0;
printf("Digite a quantidade de gols do primeiro time:\n");
scanf_s("%d", &placar1);
while ((c = getchar()) != '\n' && c != EOF) {}
printf("Digite a quantidade de gols do segundo time:\n");
scanf_s("%d", &placar2);
while ((c = getchar()) != '\n' && c != EOF) {}
printf("O placar do jogo foi %d a %d\n", placar1, placar2);
printf("Apostador 1. Digite o seu nome:\n");
gets_s(bet1n);
printf("Apostador digite a quantidade de gols do primeiro time:\n");
scanf_s("%d", &bet1a);
while ((c = getchar()) != '\n' && c != EOF) {}
printf("Apostador digite a quantidade de gols do segundo time:\n");
scanf_s("%d", &bet1b);
while ((c = getchar()) != '\n' && c != EOF) {}
calculo(p1, bet1a, bet1b);
printf("%d", p1); // aqui so retorna 0
printf("Apostador 2. Digite o seu nome:\n");
gets_s(bet2n);
printf("Apostador 3. Digite o seu nome:\n");
gets_s(bet3n);
printf("Apostador 4. Digite o seu nome:\n");
gets_s(bet4n);
printf("Apostador 5. Digite o seu nome:\n");
gets_s(bet5n);
system("pause");
return 0;
}
int calculo(int pontos, int placar1, int placar2) {
if (placar1 < placar2)
{
pontos = 10;
if (placar1 == 0)
{
pontos = pontos + 5;
}
if (placar2 == 4)
{
pontos = pontos + 5;
}
return (pontos);
}
else {
if (placar1 == 0)
{
pontos = pontos + 5;
}
if (placar2 == 4)
{
pontos = pontos + 5;
}
return (pontos);
}
}
And what did you want to return?
– Victor Stafusa
The value of points summed after condition
– Mateus Eleuterio
The function is basically not working, instead of P1 receiving the value of the points summed, it is getting 0
– Mateus Eleuterio
Your function is set to receive 3 integers as parameters, but you are invoking it with an integer and two strings, as well as disregarding the return value. You are using parameter-by-value passage and therefore will not change the value of the variable in the calling program.
– anonimo
strings? but bet1a and bet1b are in int, and what is my error in return value? I am beginner, I believe that revert return the value of points using the variable points.
– Mateus Eleuterio
I got confused with the variable names, but you are disregarding the return value of the function and therefore printing the value with which the function was called and which is not modified by the function, which in this case is 0.
– anonimo
And how I find that?
– Mateus Eleuterio
Put a variable to receive the return value of the calculation function
– FourZeroFive