c++ Problem

Manish Goyal

Manish Goyal

@manish-r2Hoep Oct 23, 2024
1:-Write a Program to print 1 to 100 ....without using any loop?

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • dipen30

    dipen30

    @dipen30-hGOPpa Dec 28, 2009

    void main()
    {
    static int i = 1;

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

    if(i!=101)
    main();
    }
  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Dec 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
  • dipen30

    dipen30

    @dipen30-hGOPpa Dec 28, 2009

    which error it gives can you tell me? because it runs in my pc.
  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Dec 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
  • dipen30

    dipen30

    @dipen30-hGOPpa Dec 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.
  • Prasad Ajinkya

    Prasad Ajinkya

    @prasad-aSUfhP Dec 28, 2009

    Try writing it as a recursive function and calling the function through main.
  • Prasad Ajinkya

    Prasad Ajinkya

    @prasad-aSUfhP Dec 28, 2009

    One more - why not just print 1 to 100 😛
  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Dec 28, 2009

    kidakaka
    One more - why not just print 1 to 100 😛
    nice one ...dude...😛😛
  • silverscorpion

    silverscorpion

    @silverscorpion-iJKtdQ Dec 29, 2009

    kidakaka
    One more - why not just print 1 to 100 😛
    I thought the same after reading the question!! 😎