Hello folks, hope you people are doing well..
I have tried some of the techniques to print 100 to 1 without using any loops in the program. So here are some of the best suitable techniques. Actually I only have one right now, but will surely share others as soon as I get some better differences between them to share.
Main concept here is to use Recursion.
Method #1:
Later Folks...... :)
I have tried some of the techniques to print 100 to 1 without using any loops in the program. So here are some of the best suitable techniques. Actually I only have one right now, but will surely share others as soon as I get some better differences between them to share.
Main concept here is to use Recursion.
Method #1:
#include <iostream>
using namespace std;
void printvals(int);
void printvals(int n)
{
if(n!=0)
{
cout<<n<<" ";
printvals(--n);
}
}
int main()
{
int i=100;
printvals(i);
return 0;
}
Later Folks...... :)
0 comments:
Post a Comment