-2
You have to declare the variables day, month and year within main to be able to send them as function parameters.
Validation within int Date will need to be a conditional: if(dia > 0 && mes > 0 && ano > 0)
if you get into that if you give a return 1;
for real and in the else
one return 0;
for false.
On main you check if(Data(dia, mes, ano) == 1)
, if you enter this condition you call the function int valido
that will need parameters as well.
Will stay like this:
int data(int dia, int mes, int ano)
{
if(dia > 0 && mes > 0 && ano > 0)
return 1; //Os valores são válidos.
else
return 0; //Algum dos valores ou todos são inválidos.
}
int valido(int dia, int mes, int ano)
{
printf("Curitiba, %i/%i/%i \n", dia, mes, ano);
return 1;
}
int main()
{
int dia, mes, ano;
printf("Digite o dia, mes e ano consecutivamente: ");
scanf("%i %i %i", &dia, &mes, &ano);
if(data(dia, mes, ano) == 1)
{
printf("\nA data eh: \n\n");
valido(dia, mes, ano);
}
else
printf("\nValores invalidos. \n");
return 0;
}
What went through your mind when you did
validacao = dia, mes, ano>0;
? Review the syntax used by the C language. You are making areturn Data;
but did not define the variableData
.– anonimo
In the second row of the Data vc function you are using the operator
,
(comma). It works to concatenate instructions and returns the value of the last.validacao = dia, mes, ano>0
would be the same asdia != 0; mes != 0; validacao = ano > 0;
, that is, n makes no sense. Right would bevalidacao = dia > 0 && mes > 0 && ano > 0;
. Invoid main()
you need to create the variablesint dia, mes ano;
and inint Data()
you need to return an integer number.– aviana