COM SCI 31 Lecture Notes - Lecture 9: Local Variable, Ebcdic, Infinite Loop
Document Summary
<< endl; bool isvalidphonenumber(string pn) // phone number is copied into local variable pn for the specific function. whatever happens has no effect on the original. // a valid phone number string contains exactly 10 digit characters int numberofdigits = 0; for (int k = 0; k != pn. size(); k++) numberofdigits++; return (numberofdigits == 10); string digitsof(string pn) Normaly, arguments to a fcn are copied into the corresponding parameters. Alternatively, arguments can be passed by reference : parameter is just another name for the argument, not a copy of it polartocartesian(double rho, double theta, double xx, double yy); // not right can"t write a fcn that returns more than one value need 2 doubles - use them as last two parameters. #include // gives u access to cos and sin fcns int main() double r; double angle; The rest of this iteration equivalent form: (one less level of nesting) for ( ; . if ( )