Programming in C+ Program With Several Functions main function square function cube function
6 Program With Several Functions main function square function cube function
Programming in C+ Program With Three Functions include <iostream> int Square( int )i / declares these two int Cube( int )i // value-returning functions using namespace std int main() cout < wThe square of 27 is w < Square(27)<< endl y£ unction ca11 cout < uThe cube of 2 is 1 < Cube(27)<< endl / function call return 0 7
7 Program With Three Functions #include <iostream> int Square( int ); // declares these two int Cube( int ); // value-returning functions using namespace std ; int main( ) { cout << “The square of 27 is “ << Square(27) << endl; // function call cout << “The cube of 27 is “ << Cube(27) << endl; // function call return 0; }
Programming in C++ Rest of Program int Square( int n) return n"n; int Cube( int n return n*n*n
8 Rest of Program int Square( int n ) { return n * n; } int Cube( int n ) { return n * n * n; }
Programming in C++ Output of program The square of 27 is 729 The cube of 27 is 19683
9 Output of program The square of 27 is 729 The cube of 27 is 19683
Programming in C+ Every C++ function has 2 parts int main() heading body block return o
Every C++ function has 2 parts int main ( ) heading { body block return 0; }