- Home
- Interview Questions
- C Programming
You should make your code easy to understand. If you nest if statements, they will be evaluated If you use a single compound statement, the expressions are evaluated only until the entire statement evaluates to false.
As the names imply, unary operators work with one variable, and binary operators work with two.
It's both! The compiler is smart enough to know which one you’re using. It knows
which form to use based on the number of variables in the expression that is used.
In the following statement, it is unary:
x = -y;
versus the following binary use:
x = a - b;
An expression is anything that evaluates to a numerical value.
The relative precedence of the operators.
a = x++;
a = ++x;
After the first statement, the value of a is 10, and the value of x is 11. After the second statement, both a and x have the value 11. (The statements must be executed separately.)
The compound assignment operators let you combine a binary mathematical operation with an assignment operation, thus providing a shorthand notation. The compound operators are +=, -=, /=, *=, and %=.
The factorial function is a prime example of using recursion. The factorial number is needed in many statistical calculations. Recursion is just a loop; however, it has one difference from other loops. With recursion, each time a recursive function is called, a new set of variables is created.
Yes. If an instance of a class can be created without arguments, then the class is said to have a default constructor. A class can have only one default constructor.
No. It is a standard in C that the main() function is the first function to execute; however, it can be placed anywhere in your source file. Most people place it either first or last so that it’s easy to locate.