Declaration must be placed after the opening braces of the main() function.all declarations must come before the first executable(non-declaration) statements of the program.
all types of variables must be declared before they are used.
When Naming a Variable :
1.Variable name must begin with a letter of alphabet.In C underscore(_) is considered as a letter
2.Compiler treats uppercase and lowercase letters as different
3.No special characters, such as blank space,period,semicolon,comma, or slash are permitted in variable names
what is a variable ?
it is a symbolic name for a memory location in which assigned value is stored
Comments:
It is easier to put in the comments as you code the program rather than after the entire program has been completed.
Variable Initialization :
It is not sufficient to declare a variable before it is used, the variable must also be initialized.
the compiler doesn't automatically assign 0 to it when it is created.
void main(){
int a;
printf("%d",a);
getch();
}
prints the garbage value.when i try to run the output is
Integer Truncation Error :
fractional parts are truncated into integers which leads to horrendous errors\
Note: printf the letter f in that stands for either function or formatted
[In Progress]
No comments:
Post a Comment