Coupon Accepted Successfully!


Question 1

Whats short-circuiting in C expressions?

What this means is that the right hand side of the expression is not evaluated if the left hand side determines the outcome. That is if the left hand side is true for || or false for &&, the right hand side is not evaluated.

Question 2

Whats wrong with the expression a[i]=i++; ? Whats a sequence point?

Although its surprising that an expression like i=i+1; is completely valid, something like a[i]=i++; is not. This is because all accesses to an element must be to change the value of that variable. In the statement a[i]=i++; , the access to i is not for itself, but for a[i] and so its invalid. On similar lines, i=i++; or i=++i; are invalid. If you want to increment the value of i, use i=i+1; or i+=1; or i++; or ++i; and not some combination.

A sequence point is a state in time (just after the evaluation of a full expression, or at the ||, &&, ?:, or comma operators, or just before a call to a function) at which there are no side effects.

The ANSI/ISO C Standard states that

Between the previous and next sequence point an object shall have its stored
value modified at most once by the evaluation of an expression. Furthermore, 
the prior value shall be accessed only to determine the value to be stored.

At each sequence point, the side effects of all previous expressions will be completed. This is why you cannot rely on expressions such as a[i] = i++;, because there is no sequence point specified for the assignment, increment or index operators, you don't know when the effect of the increment on i occurs.

The sequence points laid down in the Standard are the following:


  • The point of calling a function, after evaluating its arguments.
  • The end of the first operand of the && operator.
  • The end of the first operand of the || operator.
  • The end of the first operand of the ?: conditional operator.
  • The end of the each operand of the comma operator.
  • Completing the evaluation of a full expression. They are the following:

    • Evaluating the initializer of an auto object.
    • The expression in an ?ordinary? statement?an expression followed by semicolon.
    • The controlling expressions in do, while, if, switch or for statements.
    • The other two expressions in a for statement.
    • The expression in a return statement.

Question 3

What is the difference between a statement and a block?

A statement is a single C expression terminated with a semicolon. A block is a series of statements, the group of which is enclosed in curly-braces.

Question 4

Can comments be nested in C?


Question 5

What is type checking?

The process by which the C compiler ensures that functions and operators use data of the appropriate type(s). This form of check helps ensure the semantic correctness of the program.

Question 6

Why can't you nest structure definitions?

This is a trick question!

You can nest structure definitions.

struct salary
    char empname[20];
        int dearness;

Question 7

What is a forward reference?

It is a reference to a variable or function before it is defined to the compiler. The cardinal rule of structured languages is that everything must be defined before it can be used. There are rare occasions where this is not possible. It is possible (and sometimes necessary) to define two functions in terms of each other. One will obey the cardinal rule while the other will need a forward declaration of the former in order to know of the former's existence.

Question 8

What is the difference between the & and && operators and the | and || operators?

& and | are bitwise AND and OR operators respectively. They are usually used to manipulate the contents of a variable on the bit level. && and || are logical AND and OR operators respectively. They are usually used in conditionals

Question 9

Is C case sensitive (ie: does C differentiate between upper and lower case letters)?

Yes, ofcourse!

Question 10

Can goto be used to jump across functions?


This wont work

  int i=1;
  while (i<=5)
    if (i>2)
        goto here;


Test Your Skills Now!
Take a Quiz now
Reviewer Name