Archemedian's ghost resides in your comp

cpp India
  • 19 years ago

    can any body explain to me about the strange behaviour of this program

    include<stdio.h>


    include<conio.h>


    void main()
    { long a,b,c;
    clrscr();
    printf("archimidianripplets");
    for(a=1;a<=40;a++)
    for(b=a;b<=40;b++)
    for(c=b;c<=40;c++)
    if(((aa)==(bb)+(cc))||((bb)==(aa)+(cc))||((cc)==(bb)+(aa)))
    /
    mark/
    printf(" \t%ld \t%ld \t%ld \n");
    /
    mark  do not give variables in printf*/


    getch();
    }





    notice that there are no variables given in the printf statement yet it prints the required values correctly
    (in the reverse order that is ;-) )
    yet how can it happen?
    I discovered this accidently
    the tripplets were being displayed in reverse order . So i decided to change the order of the variables  in the printf statement : But to my utter amazement  i had not at all given the variables in the printf statement



    compile it in Turbo C to get the effect

  • 19 years ago

    I'm afraid it does not work correctly on all machines, depending on the compiler you are using and how memory is allocated/accessed; if I compile it with lcc-win32 I get an absolutely insignificant print, under cigwin it is even worst ...



Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“C++: an octopus made by nailing extra legs onto a dog.” - Steve Taylor