"Walter Roberson" <> wrote in message
news:fjpe4i$cum$...
> In article
> <a1c0f3d0-8065-47c5-bd8c->,
> user923005 <> wrote:
>>On Dec 12, 11:12 am, jayapal <jayapal...@gmail.com> wrote:
>>> #include <stdio.h>
>
>>> main ()
>>> {
>>> int k = 10;
>>> printf ( "%f\n", k);
>
>>> }
>
>>This should do what you want. Look at
>>each difference between this program and your program. Each
>>difference is important.
>
>>#include <stdio.h>
>>int main(void)
>>{
>> const int k = 10;
>> printf("%f\n", (double) k);
>> return 0;
>>}
>
> What is the "important" difference between using int k = 10 or
> const int k = 10 ?
The important difference is that an integer that is not modified by the
program should be made const.
> Will the abstract behaviour of the program
> be different in -any- way by using 'const' or not using 'const'
> in that program?
The abstract behavior is not different. The difference is in maintenance of
such a program. 80% of the cost of software is in maintenance. Anything
you can do to reduce bugs is worthwhile. While this example is trivial, the
general practice is what is wanted.
> Is there, for example, a difference in the
> behaviour of the cast to double?
No.
> Why is it important that k be const
> but that you do not cast k to (const double) ?
It is a parameter to a function call. It is only passing a copy anyway. Is
this a troll?
--
Posted via a free Usenet account from
http://www.teranews.com