+ 5
What is the meaning of ++b
13 Respostas
+ 7
case1)
int a=++b;
//it mean value of b increases by 1 & a=b+1;
case2)
b=++b;
//it means value of b increased by 1
//but if b++ here , then no increment
+ 4
Pre-increment. Increase 'b' by one and operate.
+ 4
it counts the integer b + 1
+ 1
i had problem with the following code
a=2;
b=3;
b=a++;
cout<<++b;
+ 1
@Varun
When in doubt, create logs in your code to see values.
https://code.sololearn.com/ceiEl4h4gKy5/#cpp
#include <iostream>
using namespace std;
int main() {
int a=2;
int b=3;
// Display our initial values.
cout << "Variable a = " << a << "\n";
cout << "Variable b = " << b << "\n";
b=a++;
cout << "b = a++ is equal to " << b << "\n";
// Because a++ is post-increment, it increases AFTER we assigned the value to 'b'
cout << "Afterward 'b' is equal to " << b << endl;
cout << "Afterward 'a' is equal to " << a << endl;
// In this case, we increase the value of b BEFORE we assign it, so we get 3.
cout << "Pre-increment 'b' variable to get " << ++b << "\n";
cout << "End result for b: " << b << endl;
return 0;
}
::: OUTPUT :::
Variable a = 2
Variable b = 3
b = a++ is equal to 2
Afterward 'b' is equal to 2
Afterward 'a' is equal to 3
Pre-increment 'b' variable to get 3
End result for b: 3
+ 1
Hi dude !
It's means that before using the variable's value the Compiler increase the value by one
+ 1
The solution of about problem is that
In 3rd line b=a++ means the value of a++ goes into b so now the value of b is 2 and when while cout before read the variable by Compiler it increases by 1 so the net value is 3
The confusion may be in a++ =2
It is because in starting the value of a is 2 and that value goes to b now if we use 'a' further so we have to put the value of a =3
+ 1
Brother first read the whole conversation and then give your views
0
It means the value of b increases by 1.It is pre-increment.
0
increment
0
++b is preincrement operator. Actually it first increments a given value,then the incremented value is assigned to the variable
- 2
anyone hacker here?
- 3
prefix increment operator