I have this assignement to make a simple calculator. But one of the exercises is to take the value of the division and divide it for another number. I made functions for this and what I need help with is, how to take the value returned from the function and use it again. Should I use pointers or store it in an array? TY
This is what I got so far:
int op;
int x, y, z;
printf("\n4.Divisão '/'\n\n");
scanf("%d", &op);
//Asks the user for the values
printf("x:");
scanf("%d", &x);
printf("y:");
scanf("%d", &y);
printf("\nDivisão: %d / %d = %.1f", x, y, divide (x, y)); //Basic division
printf("Outro valor:"); //Asks for another variable
scanf ("%d", &z); //Reads the variable
/*printf("\nDivisão 2 : %.1f / %d = %.1f", div, z, divide (div, z));*/
//Tried to use function variable, don't mind this
//Should it be a recursive function?
double divide (int a, int b)
{
float div;
div = a / b;
return div;
}