Example HTML page

Assignment 2: Modify Operators (MCQ)

1. What is the output of the following?

int main()
int var=5;
printf(“%d\n”, var++);

return 0;

2. Evaluate the following expressions;


3. What is the output of the following?

void main()

int i=0, j=1, k=2, m;
m = i++ || j++ || k++;
printf("%d %d %d %d", m, i, j, k);
Hint: In an expression involving || operator, evaluation takes place from left to right and will be stopped if one of its components evaluates to true(a non zero value). So in the given expression m = i++ || j++ || k++. It will stop at j and assign the current value of j in m. therefore m = 1 , i = 1, j = 2 and k = 2 (since k++ will not encounter. so its value remain 2)
4. What is the output of the following.
  1. #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 0;
  5.         int x = i++, y = ++i;
  6.         printf("%d % d\n", x, y);
  7.         return 0;
  8.     }

5. What is the output of the following..

  1. #include <stdio.h>
  2.     void main()
  3.     {
  4.         int x = 97;
  5.         int y = sizeof(x++);
  6.         printf("X is %d", x);
  7.     }

Hint: The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type. The size is determined from the type of the operand. The result is an integer. If the type of the operand is a variable length array type, the operand is evaluated; otherwise, the operand is not evaluated and the result is an integer constant.

6. What is the output of the following Program?

void main()
int a=100, b;
b = a++ + ++a;
printf(“%d %d %d %d”, b, a++, a, ++a);

Example HTML page

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest