Q. What is the value of 'a' after this code?

Code:
#include <stdio.h>
int main() {
    int a = 5;
    a = a++;
    printf("%d", a);
    return 0;
}
  • (A) 5
  • (B) 6
  • (C) Undefined
  • (D) Compilation Error
πŸ’¬ Discuss
βœ… Correct Answer: (A) 5
Explanation: a++ returns the value before incrementing, and assignment overwrites the change.
Explanation by: Mr. Dubey
a++ returns the value before incrementing, and assignment overwrites the change.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
105
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
82%
Success Rate