Chap 3 CPP 6 TH
Chap 3 CPP 6 TH
Function Basics
• I-P-O
– Input – Process – Output
– Basic subparts to any program
– Use functions for these "pieces"
• return statement
– Sends data back to caller
• Global variables?
– Possible, but SELDOM-USED
– Dangerous: no control over usage!
• Loop blocks:
for (int ctr=0;ctr<10;ctr++)
{
sum+=ctr;
}
– Variable ctr has scope in loop body block only