print 1 to n

Write a code in C to print 1 to n without using any loop and inbuilt function.

Comments

  1. void print(int x,int y)
    {
    int i =x;
    LABEL:
    printf("%d\n",i++);
    if(i>y)
    return;
    else
    goto LABEL;
    }

    ReplyDelete
  2. #include

    using namespace std;

    void print_100(int n)
    {
    if(n<0)
    return;
    print_100(n-1);
    cout<<n;
    }

    int main()
    {
    print_100(100);
    return 0;

    }

    ReplyDelete
  3. @ankit yes it will work fine..:)

    ReplyDelete

Post a Comment

Popular posts from this blog