CrazyEngineers
  • c++ Problem

    Manish Goyal

    Member

    Updated: Oct 23, 2024
    Views: 900
    1:-Write a Program to print 1 to 100 ....without using any loop?
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • dipen30

    MemberDec 28, 2009

    void main()
    {
    static int i = 1;

    printf("%d ",i++);

    if(i!=101)
    main();
    }
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberDec 28, 2009

    dipen30
    void main()
    {
    static int i = 1;

    printf("%d ",i++);

    if(i!=101)
    main();
    }
    Have you execute this code...?
    actually it is giving error in my computer...
    check it out
    Are you sure? This action cannot be undone.
    Cancel
  • dipen30

    MemberDec 28, 2009

    which error it gives can you tell me? because it runs in my pc.
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberDec 28, 2009

    dipen30
    which error it gives can you tell me? because it runs in my pc.
    Cannot call 'main' from withing in the program in function main();
    and I am using Borland C++ Compiler 5.5
    Are you sure? This action cannot be undone.
    Cancel
  • dipen30

    MemberDec 28, 2009

    I am using Turbo c.

    I think in your compiler we cannot call main within main. but this code is run correctly in my compiler.

    Use turbo c to run this code.
    Are you sure? This action cannot be undone.
    Cancel
  • Prasad Ajinkya

    MemberDec 28, 2009

    Try writing it as a recursive function and calling the function through main.
    Are you sure? This action cannot be undone.
    Cancel
  • Prasad Ajinkya

    MemberDec 28, 2009

    One more - why not just print 1 to 100 😛
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberDec 28, 2009

    kidakaka
    One more - why not just print 1 to 100 😛
    nice one ...dude...😛😛
    Are you sure? This action cannot be undone.
    Cancel
  • silverscorpion

    MemberDec 29, 2009

    kidakaka
    One more - why not just print 1 to 100 😛
    I thought the same after reading the question!! 😎
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register