You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
525 B
C++
25 lines
525 B
C++
Fig01_04.cpp - Recursive routine to print numbers, with a test program
|
|
|
|
#include <iostream.h>
|
|
|
|
void printDigit( int n )
|
|
{
|
|
cout << n;
|
|
}
|
|
|
|
/* START: Fig01_04.txt */
|
|
void printOut( int n ) // Print nonnegative n
|
|
{
|
|
if( n >= 10 )
|
|
printOut( n / 10 );
|
|
printDigit( n % 10 );
|
|
}
|
|
/* END */
|
|
|
|
int main( )
|
|
{
|
|
printOut( 1369 );
|
|
cout << endl;
|
|
return 0;
|
|
}
|