0
How can we print 1 to 100 without using any loop and goto in c language
4 Answers
+ 4
you can use recursion
https://code.sololearn.com/c9658toJaf9H/?ref=app
+ 2
cout << 1;
cout << 2;
...
...
...
cout << 100;
Copy and paste 100 times.
Or you can make a recursive function.
+ 2
#include <iostream>
void iterate(int j);
void add(int k);
int main(int argc, char *argv[])
{
int i=0;
iterate(i);
}
void iterate(int j)
{
j++;
std::cout<<j<<std::endl;
if(j<100)
{
add(j);
}
}
void add(int k)
{
k++;
std::cout<<k<<std::endl;
if(k<100)
{
iterate(k);
}
}
+ 1
cout<<1,2,3....98,99,100;