Please explain me about Prefix and Postfix | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 2

Please explain me about Prefix and Postfix

exp. x=10 y=6 y=x++ cout<<++y; and, wht about 3 or more variable? many thanks.

22nd Dec 2016, 3:08 PM
Bapak Antok
Bapak Antok - avatar
2 Réponses
+ 3
Prefix : = ++x; postfix = x++; prefix adds the value of the variable by 1 before processing the line of code. Postfix processes the line of code before adding the value of the variable by 1. Example : int x = 10; int y = ++x; // x and y becomes 11. int z = y++; // y becomes 12 , z becomes 11.
22nd Dec 2016, 3:25 PM
Wen Qin
Wen Qin - avatar
0
many thanks, K2
23rd Dec 2016, 7:00 AM
Bapak Antok
Bapak Antok - avatar