Skip to content

Instantly share code, notes, and snippets.

@housemeow
Created January 20, 2013 07:23
Show Gist options
  • Save housemeow/4577140 to your computer and use it in GitHub Desktop.
Save housemeow/4577140 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
void printIterative(int upbound)
{
int i;
for(i=0;i<=upbound;i++)
{
printf("%d ", i);
}
printf("\n");
}
void printRecursive(int now, int upbound)
{
if(now<=upbound)
{
printf("%d ", now);
printRecursive(now+1, upbound);
}
else
{
printf("\n");
}
}
int main(int argc, char*argv[])
{
printf("printIterative\n");
printIterative(5);
printf("printRecursive\n");
printRecursive(0, 5);
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment