There are certain reserved words in ‘C’, which are called keywords. The compiler already knows meaning of keywords. Following are few standard keywords
auto break case extern float far
sizeof static struct
They are all written with small case letters. Keywords cannot be used as variable name as it will alter their meaning.
Operands, operators and Expression
• Arithmetic operators
• Unary operators
• Assignment operators.
Operands and operators are both together used to form expressions. Data items that operators act upon are called operands. Operands can be constants or variables. When all the operands in an expression are constant it is called a constant expression. Most operators require two operands to operate upon. They are called binary operators.
Some operators require single operands; they are called unary operators. We will see how arithmetic operators; unary operators and assignment operators are used.
There are five arithmetic operators in ‘C’
The operands must be numeric values i. e. they can be integer quantities, floating point or character quantities (each character represents an integer value). When both operands of division operator (/) are integers, result is an integer. It is called integer division. Integer division result in truncation towards zero. If both operands are floating point or if one is floating point and one is integer, result is floating point.
There is no operator for exponentiation in ‘C’.
Arithmetic instruction can be formed as
The expression on the right of ‘=’’ is evaluated and assigned to variable on the left hand side of ‘=’. As it is seen initialization can be done during declaration.
Minus sign precedes a numerical constant, a variable or an expression. It is used for negation. It is different from arithmetic subtraction operator.
E. g. -1 -3.0
Increment and Decrement Operator
These are used for incrementing and decrementing variables. Increment operator ‘++’ adds 1 to its operand, while decrement operator ‘_’ subtracts 1 from its operand. The operator may be postfixed or prefixed. Postfixing and prefixing makes a difference when the operators are used in expression.
E. g.j++ ; ++j ;
Both are same when used as simple statements.
If we havej = 3 ; X = j+ + ;
Here j is first assigned to x and then increment by 1. Hence X = 3, J = 4;X = + + j ;
Here j is first incremented and then assigned to x. Hence x = 4, j = 4;
It returns the size of its operand in bytes.
will give j = 2. (Since integer occupies 2 bytes and i is an integer).
When we write an expression
Here ‘=’ is the assignment operator. In this case expression on the right of ‘=’ is evaluated and value is assigned to the variable on the left.
There is one more type of assignment operator. If we have an expression where variable on the left is repeated immediately on the right, it can be written as:i = i + 2 ; i + = 2 ;
The operator ‘+’ is called the assignment operator. Most binary operators have corresponding assignment operators. General form of assignment expression beingexpr1 op = expr2 ;
Insteadexpr1 = (expr1) op (expr2) ;
Where expr1 and expr2 are expressions and op can be one of the operators.
+ - * / % << >> & ^ |
There are more five operators known as bitwise operators which would be taken up in miscellaneous
This type of assignment operators make long expression easy to work with.
E. g.yyval [yypv [p3 + p4] + yypv [p1 + p2] ] + = 2; is easier than yyval [yypv [p3 + p4] + yypv [p1 + p2] ] = yyval [yypv [p3 + p4] + yypv [p1 + p2] ] + 2 ;
C Related Interview Questions
|DBMS Interview Questions||C++ Interview Questions|
|C & Data Structures Interview Questions||Java Interview Questions|
|Go (programming language) Interview Questions||F Sharp (programming language) Interview Questions|
|C preprocessor Interview Questions||R Programming language Interview Questions|
|D Programming Language Interview Questions||Lua (programming language) Interview Questions|
|Embedded C Interview Questions|
Introduction To C-programming
Data Types And Storage Classes
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.