Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
23 views1 page

Recursive

The document demonstrates recursion through a function that reads a line of text from the keyboard and outputs it in reverse order by recursively calling itself and printing each character.

Uploaded by

san sonny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views1 page

Recursive

The document demonstrates recursion through a function that reads a line of text from the keyboard and outputs it in reverse order by recursively calling itself and printing each character.

Uploaded by

san sonny
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

// recursive.

cpp
// Demonstrates the principle of recursion by a
// function, which reads a line from the keyboard
// and outputs it in reverse order.
// ----------------------------------------------------
#include <iostream>
using namespace std;
void getput(void);
int main()
{
cout << "Please enter a line of text:\n";
getput();
cout << "\nBye bye!" << endl;
return 0;
}
void getput()
{
char c;
if( cin.get(c) && c != '\n')
getput();
cout.put(c);
}

You might also like