The tag has no usage guidance.

learn more… | top users | synonyms

1
vote
1answer
39 views

How to compute whether it is guaranteed the variable is set?

Assuming declarations are expressions consider such code: if ((var x = foo()) and (var y = x)) or (var z = bar()) then println(z); end The reference to x is OK, because at this point x has to be ...
-3
votes
3answers
105 views

Best way to handle variables used in a for loop? [duplicate]

From previous experience, I had always thought that, if you are going to use variables inside of a for loop, it was much better to declare them outside of the loop vs. inside the loop itself. I ...
6
votes
3answers
2k views

Is it good to define a variable inside a loop? [closed]

My instructor once told me that I should not define a variable inside a loop, but I honestly still do not understand why. What are the disadvantages of that? Could any body explain that to me?
0
votes
3answers
318 views

Understanding the concept of “arguments” and “parameters”

In the third last paragraph at page number 26 of the ebook "The C Programming Language" the author(s) say, "We will generally use parameter for a variable named in the parenthesized list in a ...
13
votes
5answers
4k views

Why is *declaration* of data and functions necessary in C language, when the definition is written at the end of the source code?

Consider the following "C" code: #include<stdio.h> main() { printf("func:%d",Func_i()); } Func_i() { int i=3; return i; } Func_i() is defined at the end of the source code and ...
19
votes
4answers
3k views

Why do we have to mention the data type of the variable in C

Usually in C, we have to tell the computer the type of data in variable declaration. E.g. in the following program, I want to print the sum of two floating point numbers X and Y. #include<stdio.h&...
0
votes
2answers
134 views

Where are C variables declared [duplicate]

I see a lot of code with variables declared right after the function, but when I post something like that people end up mad and say it is better to declare them when they are used. I assume this all ...
5
votes
3answers
670 views

Declaring variables in Python and PHP

The question is how to cope with absence of variable declaration in Python, PHP, and the like. In most languages there is a way to let the compiler know whether I introduce a new variable or refer to ...
2
votes
2answers
453 views

Is there a difference between declaring variables outside or inside a loop? [closed]

Is there any difference if I were to write something like this: int row,col; for(row = 0; row < data.length; row++){ for(col = 0; col < data[row].length;col++){ //do ...
0
votes
3answers
2k views

Declaring a field name starting with underscore [duplicate]

Before forming a class in Java or other programming languages that support OOP, should I use underscore (_) in each (local or private) field declaration. More precisely: private String ...
6
votes
8answers
593 views

What is the possible disadvantage of putting declarations in inner blocks, instead of at beginning of function?

At the place where I work, there are explicit guidelines for placement of declarations of variables. According to that, it is required to put them at the global level and / or at the beginning of ...
7
votes
4answers
604 views

Reason behind multi-line declaration style?

I'm a little curious about the reason behind the Windows header file declaration styles. When I read them, I see multi-line declarations such as the following: WINBASEAPI HANDLE WINAPI GetStdHandle( ...