0

Hi why we use x+1 please

30th Jun 2020, 2:10 PM
Umais Khan
Umais Khan - avatar
7 odpowiedzi
+ 1
Where? • Please be specific with your question. • Attach code link or lesson link with which you have doubt.
30th Jun 2020, 2:12 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 1
x+1 or i+1 or in fact with any variable, this will increase value of that that variable by 1 but it won't store it to the variable. int x = 5; cout << x + 1; //this will print 6 cout << x; //but value of x is still 5. • Now if you want to change value of x with increment by 1 you have to re-initialize it. int x = 5; x = x + 1; cout << x; //now this will print 6
30th Jun 2020, 2:18 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 1
In my opinion it is a very powerful statement if we initialize x=5. And x=x+1; And if it runs automatically it causes the value to increment .it also reduces large lines of codes.
1st Jul 2020, 6:28 AM
Uzair
Uzair - avatar
0
Ok
30th Jun 2020, 2:13 PM
Umais Khan
Umais Khan - avatar
0
[i+1]
30th Jun 2020, 2:14 PM
Umais Khan
Umais Khan - avatar
0
Something like this
30th Jun 2020, 2:14 PM
Umais Khan
Umais Khan - avatar
0
Tnx bro
30th Jun 2020, 2:21 PM
Umais Khan
Umais Khan - avatar