c++ Problem

1:-Write a Program to print 1 to 100 ....without using any loop?

Replies

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

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

    if(i!=101)
    main();
    }
  • Manish Goyal
    Manish Goyal
    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
    which error it gives can you tell me? because it runs in my pc.
  • Manish Goyal
    Manish Goyal
    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
    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
    Try writing it as a recursive function and calling the function through main.
  • Prasad Ajinkya
    Prasad Ajinkya
    One more - why not just print 1 to 100 ๐Ÿ˜›
  • Manish Goyal
    Manish Goyal
    kidakaka
    One more - why not just print 1 to 100 ๐Ÿ˜›
    nice one ...dude...๐Ÿ˜›๐Ÿ˜›
  • silverscorpion
    silverscorpion
    kidakaka
    One more - why not just print 1 to 100 ๐Ÿ˜›
    I thought the same after reading the question!! ๐Ÿ˜Ž

You are reading an archived discussion.

Related Posts

Guys whenever i see the coding of any web page on a web Browser...I wondered why this line is written on start of any webpage... why it is required...?Is it...
Guys I am not much aware of this...since years ago I heard something like that we can make clouds to thunder according to our wish ..by puting some salt on...
A lady was driving along with her father. They came upon a storm, and the young lady asked her father, What should I do?" He said "keep driving". Cars began...
Hi, I am a Mechanical student, currently at my final year so I am to do my FYP aka Final Year Project with the title of hybrid power generator (solar...
CEans, If you have been following our discussions in this sections, you might be aware that we're now starting to actively promote CE among colleges in India (to begin with...