I wrote a very basic program in C++ which asked the user to input a number and then a string. the program then prints string up-to 10 times(in my case i am mostly printing name), via recursion.code compiles fine ,but i was not getting my required output.can you help me what is the mistake.?
#include<iostream>
using namespace std;
void apple(int b,string name)
{
//int a=1;
cout<<b<<name<<endl;
//a++;
b++;
if(b<10){
apple(b,name);
}
else{
void apple();
}
}
int main()
{
string myname;
int number;
cout<<"what do you want print"<<endl;
cin>>myname;
cout<<"how MANY TIMES YOU WANT TO PRINT"<<endl;
cin>>number;
apple(number,myname);
cout<<endl;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire