1.

What do you understand by the pre-decrement and post-decrement operators?

Answer»

The Pre-decrement OPERATOR (--operand) is used for decrementing the value of the variable by 1 before assigning the variable value.

#include < stdio.h > int main(){ int x = 100, y; y = --x; //pre-decrememt OPERATORS -- first decrements the value and then it is assigned PRINTF("y = %d\n", y); // Prints 99 printf("x = %d\n", x); // Prints 99 RETURN 0; }

The Post-decrement operator (operand--) is used for decrementing the value of a variable by 1 after assigning the variable value.

#include < stdio.h > int main(){ int x = 100, y; y = x--; //post-decrememt operators -- first assigns the value and then it is decremented printf("y = %d\n", y); // Prints 100 printf("x = %d\n", x); // Prints 99 return 0; }


Discussion

No Comment Found