Hi, I want to pass the return value of function A to function B, and pass the return value of function B to function C. I'm using struct. I can pass from struct to function and then main, but turn out I'm still confuse how to pass struct return to a function which return another struct as well.
Here's how I define my struct
Code:
struct Credit {
float A;
float B;
float C;
};
struct Intermediate {
float math;
float bio;
};
Then I have my first function, with manual input value from the user. And from this function I return the value of A, B and C
Code:
struct Credit course (float x1, float y1, float x2, float y2)
{
// simple arithmetic calculation...
struct Credit result;
result.A = A;
result.B = B;
result.C = C;
return result;
}
In my second function, I need to get input from A,B,C from the previous function. And then return the value of math, bio as input from next function.
Code:
struct Intermediate grade (struct Credit point)
{
// simple calculation involving return result of previous function (A, B, C)
// I call the value using point.A , point.B and point.C
struct Intermediate result;
result.math = math;
result.bio = bio;
return result;
//result from this function will be used for the next function
}
Here's my main :
Code:
course(12,10,10,8);
grade(course());
//next function using input from function grade.
When I put the first function as input of the second function, it expected input (indeed the first function needs input) but I wanted to call the return value not the function. I'm confuse. Any advice ? Thank you