- 3
If a=10, a++=11
Need explaination in detail
11 Answers
+ 2
What do you need help with? The syntax or the comparison
+ 1
Thereâs nothing to solve, what you have stated is what would happen.
If a equals 10.
Then a (after, as using postfix increment) equals 11.
+ 1
Arham Fayyaz
a = 10, a++ is also 10 not 11 but after a++ , a is 11
Try this:
#include <iostream>
using namespace std;
int main() {
int a = 10;
cout << a++ << endl;
cout << a;
return 0;
}
if there is pre-increment like ++a then ++a is 11, and after ++a, a will also be 11
Try this:
#include <iostream>
using namespace std;
int main() {
int a = 10;
cout << ++a << endl;
cout << a;
return 0;
}
0
Please don't put tags like Pakistan
0
Bro I am just having problem due to ++ what is the value or mean of plus here so
0
Arham Fayyaz
It just simply adds the value by 1
0
Arham Fayyaz
Explain what problem you are having. I have suggest possible fixes (where not using equality operator) and explained the postfix increment is increasing the value by 1.
Here is a working example:
#include <iostream>
int main() {
int a {10};
if (a == 10)
a++;
std::cout << a;
return 0;
}
0
I think what he needs is just an explanation of what ++ does according to his question and comment đ¤
- 1
Firstly you are using an assignment operator in a comparison statement.
You would use == to check equality.
Secondly you donât assign an increment operator a value.
a++ is the same as a += 1 (or a = a + 1) and doesnât require an assignment value.
Hereâs an example:
If (a == 10):
a++
( a now equals 11)
- 2
Can you solve?
- 2
Syntax