Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Compilingtimeoffunctionprograms

I have been given task of writing simple function programs in dev C++ by my class teacher. While making those function programs I noticed that the compiling time of programs with longer name was a little longer than the one with shorter names (difference in micro seconds). I thought may it was my compiler error so I tried them on my two friend laptops. The case did not change. I was wondering what is the reason behind this change of timing, is it the compiler, or the name of functions. I did my experiments but could not find a good answer to it. Any help regarding this would be well appreciated. I have attached the screenshots of mine and my companion’s laptop results, and I am providing the codes too. Thought I thing you can try it with any functions program codes in dev C++. [1]: https://i.stack.imgur.com/OAgNB.png [2]: https://i.stack.imgur.com/nQEHt.png [3]: https://i.stack.imgur.com/DEAaQ.png [4]: https://i.stack.imgur.com/2081r.png [5]: https://i.stack.imgur.com/gR7C4.png [6]: https://i.stack.imgur.com/f4ULA.png [7]: https://i.stack.imgur.com/DM5F2.png [8]: https://i.stack.imgur.com/kr0MC.png

Code to swap to numbers using function and by using pass by value.

#include <iostream>
int swap(int &a,int &b);
main()
{int a,b;
 a=5,b=7;
 swap(a,b);
 std::cout<<"a="<<a;
 std::cout<<" ,b="<<b;
}
int swap(int &a,int &b)
{ int c=a;
 a=b;
 b=c;   
}

Code to swap to numbers using function and by using pass by value.(using a longer funtion name this time)

#include <iostream>
    int swap_numbers(int &a,int &b);
    main()
    {int a,b;
     a=5,b=7;
     swap_numbers(a,b);
     std::cout<<"a="<<a;
     std::cout<<" ,b="<<b;
    }
    int swap_numbers(int &a,int &b)
    { int c=a;
     a=b;
     b=c;   
    }

Comments