Keywords
Keywords are standard identifiers that have standard predefined meaning in C. Keywords are all lowercase, since uppercase and lowercase characters are not equivalent it's possible to utilize an uppercase keyword as an identifier but it's not a good programming practice.
Points to remember
1. Keywords can be used only for their intended purpose.
2. Keywords can't be used as programmer defined identifier.
3. The keywords can't be used as names for variables.
The standard keywords are given below:
The standard keywords are given below:
Variables
Variables are means for location in memory used by a program to store data. The size of that block depends upon the range over which the variable is allowed to vary.
For example, on personal computer the size of an integer variable is two bytes, and that of a long integer is four bytes.
A variable region is temporarily remember a number or string value, such as covered by the program. To identify the variables, you have a name unique to every single variable. This is called a variable name. Before using a variable, use variables to what is called a variable declaration that you have to reveal the names and data types that can be stored in the variable variable.
The format for declaring a variable in C.
[Storage-class] type data variable name [= initial value];
Storage class and the initial value can be omitted.
The same data type and storage class variable can be declared, separated by commas.
[Storage-class] type data variable name [= initial value] variable [= initial value] variable [= initial value];
The format for declaring a variable in C.
[Storage-class] type data variable name [= initial value];
Storage class and the initial value can be omitted.
The same data type and storage class variable can be declared, separated by commas.
[Storage-class] type data variable name [= initial value] variable [= initial value] variable [= initial value];
In C the size of a variable type such as an integer need not be the same on all types of machines. When we declare a variable we inform the compiler of two things, the name of the variable and the type of the variable. For example, we declare a variable of type character with the name i by writing:
char i;
On seeing the "char" part of this statement the compiler sets aside one bytes of memory to hold the value of the character. It also sets up a symbol table. In that table it adds the symbol i and the relative address in memory where those one byte was set aside. Thus, later if we write: i = 'x'; we expect that,at run time when this statement is executed, the value 'x' will be placed in that memory location reserved for the storage of the value of i.
Following are the rules for naming the variables:
- All variables must be declared before they can appear in executable statement.
- A declaration consists of a data type followed by one or more variable names separated by commas.Example: int a,b,c;
- Variables can be distributed among declarations in any fashion. The above declaration can be written asint a;int b,c;
- Integer type variables can be declared to be short integer for smaller integer quantities or long integer for larger integer quantities.Example:short int a,b,c;long int a,b,c;
- An integer variable can also be declared to be un signed by writing unsigned int.Example: unsigned int;
Example:
Expressions
An expression is a sequence of operators and operands that specifies computation of a value. An expression may consist of single entity or some combination of such entities interconnected by one or more operators. All expression represents a logical connection that's either true or false. Thus logical type expression actually represents numerical quantities.
In C every expression evaluates to a value i.e., every expression results in some value of a certain type that can be assigned to a variable. Some examples of expressions are shown in the table given below.
A+b
3.14*r*r
a*a+2*a*b+b*b
Example:
No comments:
Post a Comment