0
Write cpp program that print from 1 to 100 using recursion ?
3 ответов
+ 13
@Omar That is iteration, not recursion.
Recursion is something like,
void num(int i)
{
std::cout << i;
if (i < 100)
{
num(++i);
}
}
int main()
{
num(1);
}
+ 1
Thanks hatsy .
But why when u call the function in if statment the argumnt "pre-increment" ?
0
Is it like this ? \/\/\/
#include <iostream>
using namespace std;
void num(){
for(int i=1;i<=100;i++){
cout<<i<<endl;
}
}
int main() {
num();
}