GOEDUHUB Online Courses || Last Batch Student's Projects || COVID-19 Projects(AI-ML) || Universities  ||  Placement Preparation  Subscribe our youtube channel
+91-7976731765 Free Online Tutorials ||  MACHINE LEARNING || NLP ||  OpenCV || Python || DBMS || OOPs || DSA || Java || Linux/Unix ||  C Programming
0 like 0 dislike
17 views
in Tutorial & Interview questions by Goeduhub's Expert (8k points)
The increment and decrement operators exist in prefix and postfix form.

1 Answer

0 like 0 dislike
by Goeduhub's Expert (8k points)
 
Best answer
The increment and decrement operators exist in prefix and postfix form.

int a = 1;

int b = 1;

int tmp = 0;

tmp = ++a;        /* increments a by one, and returns new value; a == 2, tmp == 2  */

tmp = a++;        /* increments a by one, but returns old value; a == 3, tmp == 2 */

tmp = --b;        /* decrements b by one, and returns new value; b == 0, tmp == 0 */

tmp = b--;        /* decrements b by one, but returns old value; b == -1, tmp == 0 */

Note that arithmetic operations do not introduce sequence points, so certain expressions with ++ or -- operators may introduce undefined behaviour.

Related questions

0 like 0 dislike
1 answer 15 views
0 like 0 dislike
1 answer 8 views
0 like 0 dislike
0 answers 16 views
0 like 0 dislike
1 answer 16 views
0 like 0 dislike
1 answer 5 views
 Placements:   List of companies | Logical Reasoning Questions | Quantitative Aptitude Questions | General English Questions | Technical-MCQ and Interview Questions
 Important Lists: List of NITsList of IITsList of Exams After Graduation | List of Engineering Entrance Examinations (UG/PG)College ReviewsCollege Fest, Events & WorkshopsKnowledge ShareTrainees/Interns After 15-04-2020
Exams & Cutoffs: JEE Main | JEE Advanced | GATE | IES | ISRO List of PSUs || Cutoff-GATECutoff_IIT-JEECS-ScopeECE ScopeEE-Scope
 Download Previous Year Papers For:  GATE | IES | RAJASTHAN TECHNICAL UNIVERSITY (RTU-Kota)RPSC Technical Exams | ISRO
 Goeduhub
About Us | Contact Us   Social::   |  | 
...