any solution for this? only basic c++

i need to make this work by using basic c++:

#include <iostream>
using namespace std;

input()
{
int no;
char letter, yon;

cout<<"Please enter a letter: ";
cin>>letter;
cout<<"Please enter a number: ";
cin>>no;
cout<<"\n\nDo you want to enter again? Y-Yes N-No: ";
cin>>yon;
cout<<"\n\n";

if (yon=='y')
input();
else
cout<<letter <<no<<"\n";
}

main ()
{

input();

}

i was supposed to output all inputed inputs at the same time..
if the user choose to input 3x or more.. all her input will be outputed to. not the only last but ALL.

can someone else knows how?
get into the habit of fully qualifying function names.

input() should be void input(void)

Mind you, this is for names, not the calls.

Your problem is here
1
2
3
4
if (yon=='y')
    input();
else
    cout<<letter <<no<<"\n"; 


You're using recursion in a conditional. When the recursed function returns, it will NOT execute the cout.

Remove the else, let the cout statement stand alone.
Last edited on
Topic archived. No new replies allowed.