IP-04-Function and struct
IP-04-Function and struct
S = S1 + S2 + S3
Identification.
Body: implementation.
Body
S = S1 + S2 + S3;
}
int main()
{
int a = S + compute(); // Local variable in main.
while (a > 0)
{
int b = S + compute(); // Local variable in loop.
}
}
int compute()
{
int y = S * 2; // Local variable in function.
}
Input
Factorial
positive int
int main()
{
struct Student s1;
Student s2; // C++
}
Multiple--file project:
Multiple
Program ~ book:
main() ~ summary.
source files ~ chapters.
struct::
struct
Compound data-
data-type.
Combine data into one place.
Assignment: all members are copied.